#34425 [Bgs]: switch/case - number/string
| From: | sniper@php.net | Date: | Thu, 08 Sep 2005 10:51:13 +0000 |
| Subject: | #34425 [Bgs]: switch/case - number/string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-84723@lists.php.net to get a copy of this message | ||
ID: 34425
Updated by: sniper@php.net
Reported By: htht at mail dot bg
Status: Bogus
Bug Type: PHP options/info functions
Operating System: Debian, Linux
PHP Version: 4.4.0
New Comment:
switch..case is same as if ($do == 'add').
Cast the value to string first and you get expected result.
If you had used integers in cases, you should cast to int.
Previous Comments:
------------------------------------------------------------------------
[2005-09-08 12:47:49] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
.
------------------------------------------------------------------------
[2005-09-08 12:15:33] htht at mail dot bg
Description:
------------
There is problem with switch/case settlement, when the argument is
number an the cases are strings;
Reproduce code:
---------------
$do = 0;
switch ($do)
{
case 'add':
print 'we add';
break;
case 'upd':
print 'we update';
break;
default: // default display only
print 'we only display';
break;
}
Expected result:
----------------
we only display
Actual result:
--------------
we add
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34425&edit=1