note 32042 added to control-structures
| From: | armond at rack1 dot php dot net | Date: | Wed, 14 May 2003 16:02:02 +0000 |
| Subject: | note 32042 added to control-structures | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47967@lists.php.net to get a copy of this message | ||
From my tests, some more complex if() statements may not have desired results.
Take for instance,
$a = 79;
$b = 82;
$c = 40;
if($c == ($a || $b)) { ... }
You would think that would be stating:
"If $c equals $a or $b"
And would return false, but think again.
I have an idea of whats going on here-its equating it like a matematical equasion, and we follow the
EPMDAS order.
I haven't found a workaround, so for now we're stuck to:
if($c == $a || $c == $b) { .. }
Armond Carroll
--
http://www.php.net/manual/en/control-structures.php
http://master.php.net/manage/user-notes.php?action=edit+32042
http://master.php.net/manage/user-notes.php?action=delete+32042
http://master.php.net/manage/user-notes.php?action=reject+32042