note 107467 deleted from language.operators.assignment by tularis
| From: | tularis@php.net | Date: | Sun, 12 Feb 2012 11:30:32 +0000 |
| Subject: | note 107467 deleted from language.operators.assignment by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-186083@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
In response to [inca 15-Nov-2009 07:52]: you mistakenly equivocate $a &= $b (a bitwise
operation, where lazy evaluation isn't relevant) with the && logical operator (where it
is), by assuming it evaluates to $a = $a && $b (instead of the actual expression $a = $a
& $b). To modify your example:
<?php
function foo(){
echo 'foo';
return true;
}
$bar = false;
$bar &= foo(); // will call foo()
$bar = $bar & $foo // will call foo()
$bar = $bar && foo(); // will not call foo()
?>