note 107467 added to language.operators.assignment

From: Date: Fri, 10 Feb 2012 20:16:52 +0000
Subject: note 107467 added to language.operators.assignment
Groups: php.notes 
Request: Send a blank email to php-notes+get-186061@lists.php.net to get a copy of this message
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() ?> ---- Server IP: 69.147.83.197 Probable Submitter: 72.219.151.91 ---- Manual Page -- http://www.php.net/manual/en/language.operators.assignment.php Edit -- https://master.php.net/note/edit/107467 Del: integrated -- https://master.php.net/note/delete/107467/integrated Del: useless -- https://master.php.net/note/delete/107467/useless Del: bad code -- https://master.php.net/note/delete/107467/bad+code Del: spam -- https://master.php.net/note/delete/107467/spam Del: non-english -- https://master.php.net/note/delete/107467/non-english Del: in docs -- https://master.php.net/note/delete/107467/in+docs Del: other reasons-- https://master.php.net/note/delete/107467 Reject -- https://master.php.net/note/reject/107467 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186061) next »