note 12457 deleted from language.operators.logical by colder
| From: | colder@php.net | Date: | Fri, 20 Apr 2007 15:38:20 +0000 |
| Subject: | note 12457 deleted from language.operators.logical by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125694@lists.php.net to get a copy of this message | ||
Note Submitter: yohgaki at hotmail dot com
----
In PHP4, "and", "or", "&&", "||" -- all are
"short circuit" like in C/C++. In PHP3, I think it was not.
"Short circuit" means language stops evaluation of expression when conditions are
determined. (Most language uses short circuit evaluation for logical condition)
For example,
$a = true;
$b = false;
if ( $a || $b ) {
}
This "if" statement only evaluate $a, since $a is true and whole condition must be true.
(i.e. if $b is a function instead of value, the function will not be called)