note 83802 added to language.operators.logical
| From: | momrom at freenet dot de | Date: | Thu, 12 Jun 2008 14:10:57 +0000 |
| Subject: | note 83802 added to language.operators.logical | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140377@lists.php.net to get a copy of this message | ||
Some examples from the english manual that aren't avaiable in all languages:
Like in C, logical expressions are evaluated
from left to right until the result is known.
foo() will never get called in the following cases.
<?php
$a = (false && foo());
$b = (true || foo());
$c = (false and foo());
$d = (true or foo());
?>
"||" has a greater precedence than "="
which has a greater one than "or"
<?php
// same as ($e = (false || true)),
// expression is true and $e ist assigned to true
$e = false || true;
// same as (($e = false) or true),
// expression is true but $e is assigned to false
$f = false or true;
?>
"&&" has a greater precedence than "="
which has a greater one than "and"
<?php
// same as ($e = (true || false)),
// expression is false and $e ist assigned to false
$g = true && false;
// same as (($e = true) and false),
// expression is false but $e is assigned to true
$h = true and false;
?>
----
Server IP: 69.147.83.197
Probable Submitter: 85.214.69.6
----
Manual Page -- http://www.php.net/manual/en/language.operators.logical.php
Edit -- https://master.php.net/note/edit/83802
Del: integrated -- https://master.php.net/note/delete/83802/integrated
Del: useless -- https://master.php.net/note/delete/83802/useless
Del: bad code -- https://master.php.net/note/delete/83802/bad+code
Del: spam -- https://master.php.net/note/delete/83802/spam
Del: non-english -- https://master.php.net/note/delete/83802/non-english
Del: in docs -- https://master.php.net/note/delete/83802/in+docs
Del: other reasons-- https://master.php.net/note/delete/83802
Reject -- https://master.php.net/note/reject/83802
Search -- https://master.php.net/manage/user-notes.php