note 74622 deleted from language.operators.logical by colder

From: Date: Tue, 01 May 2007 05:44:33 +0000
Subject: note 74622 deleted from language.operators.logical by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126007@lists.php.net to get a copy of this message
Note Submitter: </Life> ---- Regarding the difference between "||" and "or". It's actually the precedence that causes this effect: <?php $res = $a || $b; // is the same as $res = ($a || $b); ?> $a is true in this case, hence $res is true (short circuit). <?php $res = $a or $b; // is the same as ($res = $a) or $b; ?> The value of the assignment is the assigned value itself, which is 'test' (as is the new value of $res). Since 'test' evaluates to true as well, $b isn't executed anymore (short circuit, just as above) - besides: $b is a statement without any effect anyway.

« previous php.notes (#126007) next »