note 106474 rejected from language.operators.logical by danbrown

From: Date: Fri, 11 Nov 2011 19:58:49 +0000
Subject: note 106474 rejected from language.operators.logical by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-184403@lists.php.net to get a copy of this message
Note Submitter: pc dot yuzer at gmail dot com ---- Brad has it backwards. if ($foo) { $foo = 5; } cannot be replaced with $foo or $foo = 5; The following, however, are equivalents if ( ! $foo) { $foo = 5; } $foo or $foo = 5; AND if ($foo) { $foo = 5; } $foo AND $foo = 5; The reason being $foo or $foo = 5 short circuits when $foo is TRUE and $foo = 5 is never called. $foo AND $foo = 5 does not short circuit if $foo is TRUE and $foo = 5 is called.

« previous php.notes (#184403) next »