note 46148 added to control-structures.switch
| From: | Dot_Whut? at osu1 dot php dot net | Date: | Thu, 30 Sep 2004 23:41:28 +0000 |
| Subject: | note 46148 added to control-structures.switch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-77636@lists.php.net to get a copy of this message | ||
If you plan on using string values for cases in your 'switch' statements, you should
consider casting your 'switch' value to a 'string':
<?php
$bug = 0;
// $bug will be converted to string instead of each 'case' being
// automatically converted to numeric data (w/ a value of zero).
switch ((string)$bug)
{
case 'fly':
echo 'flies buzz';
break;
case 'mantis':
echo 'mantes pray';
break;
default:
echo 'swat, splat, you are dead';
}
?>
----
Manual Page -- http://www.php.net/manual/en/control-structures.switch.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46148
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46148&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46148&report=yes
Search -- http://master.php.net/manage/user-notes.php