note 21808 modified in control-structures.switch by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 13:54:47 +0000 |
| Subject: | note 21808 modified in control-structures.switch by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79748@lists.php.net to get a copy of this message | ||
Be very careful when you're using text strings as cases. If the variable supplied to switch()
is an integer, the cases would be converted to integer before the comparison is made (usually to
zero). The following snippet prints "hello".
<?php
$a = 0;
switch($a) {
case 'Hello': echo "Hello";
break;
}
?>
--was--
Be very careful when you're using text strings as cases. If the variable supplied to switch()
is an integer, the cases would be converted to integer before the comparison is made (usually to
zero). The following snippet prints "hello".
$a = 0;
switch($a) {
case 'Hello': echo "Hello";
break;
}
http://php.net/manual/en/control-structures.switch.php