note 40888 modified in control-structures.switch by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 13:54:20 +0000 |
| Subject: | note 40888 modified in control-structures.switch by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79864@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.
<?php
$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".
--was--
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".
http://php.net/manual/en/control-structures.switch.php