note 83802 deleted from language.operators.logical by hholzgra

From: Date: Thu, 02 Aug 2012 15:13:53 +0000
Subject: note 83802 deleted from language.operators.logical by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189835@lists.php.net to get a copy of this message
Note Submitter: momrom at freenet dot de ---- 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; ?>

« previous php.notes (#189835) next »