note 28637 modified in control-structures.switch by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 13:54:41 +0000 |
| Subject: | note 28637 modified in control-structures.switch by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79842@lists.php.net to get a copy of this message | ||
working a bit around with it I found out that it is not possible to
compare the variable with two different values in one step like this
(system running a w2k server, apache2.0.43 & php430):
<?php
switch ($myvar) {
case ("foo" || "bar"): //do something
break;
case ("other"): //do another thing
break;
default:
}
?>
rather use:
<?php
switch ($myvar) {
case ("foo"):
case ("bar"): //do something
break;
case ("other"): //do another thing
break;
default:
}
?>
--was--
working a bit around with it I found out that it is not possible to
compare the variable with two different values in one step like this
(system running a w2k server, apache2.0.43 & php430):
switch ($myvar) {
case ("foo" || "bar"): //do something
break;
case ("other"): //do another thing
break;
default:
}
rather use:
switch ($myvar) {
case ("foo"):
case ("bar"): //do something
break;
case ("other"): //do another thing
break;
default:
}
http://php.net/manual/en/control-structures.switch.php