Reply to Re: When can I use "OR"

Your name:

Reply:


Posted by Bent Stigsen on 09/15/05 05:19

Smitro wrote:
> Hi,
>
> How come in some statements I can use:
>
> If (something) or DIE();

"or" needs two operands, so above would not not be syntactically
correct. Perhaps you meant expressions like:

if (something or die()) somefunc();

$x = somefunc() or die();

> but other times it won't work (returns an error) unless I take out the
> OR.

Can you give a concrete example.
I can't think of anything that would make "or" give an error. As far
as I know, any expression can be casted to a boolean, so it should
check out ok.

> Is there any documentation on this anywhere?

Probably not. It is not a feature of PHP as such, but rather a
"misuse" of the way PHP internally evaluates logical expressions. PHP
will stop the evaluation of a logical expression, if a continued
evaluation will not change the result.
For instance, if evaluating (true or somefunc()), somefunc will not be
called since its value does not change the result. Same would be the
case for (false and somefunc()).

/Bent

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация