note 40888 added to control-structures.switch
| From: | AlexFung at rn2 dot php dot net | Date: | Thu, 18 Mar 2004 07:06:58 +0000 |
| Subject: | note 40888 added to control-structures.switch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67000@lists.php.net to get a copy of this message | ||
I refer to the "Boolean logic does not work inside case statements" example by
"design at hyperoptix dot com" at "19-Feb-2004 12:46"
I found that his code fragment is working perfectly correct.
$x = 18;
$y = 6;
switch ($x) {
case (($y * 4) || (9 * 3)):
echo "Member";
break;
default:
echo "Not a member";
}
I don't know what he expects, but the || evaluates to true. Since $8 == true, it echoes
"Member". If we set $x=0, then it echoes "Not a member".
----
Manual Page -- http://www.php.net/manual/en/control-structures.switch.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40888
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40888&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40888&report=yes
Search -- http://master.php.net/manage/user-notes.php