#35188 [Bgs]: switch always picks case 0
| From: | daniel at assertio dot es | Date: | Fri, 11 Nov 2005 06:55:09 +0000 |
| Subject: | #35188 [Bgs]: switch always picks case 0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-88028@lists.php.net to get a copy of this message | ||
ID: 35188
User updated by: daniel at assertio dot es
Reported By: daniel at assertio dot es
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Win XP
PHP Version: 5.0.5
New Comment:
Found it explained in
http://es.php.net/manual/en/language.operators.comparison.php
" If you compare an integer with a string, the string is converted to a
number."
hth...
Previous Comments:
------------------------------------------------------------------------
[2005-11-11 03:56:44] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2005-11-11 02:47:38] daniel at assertio dot es
Description:
------------
If a switch case is 0 and the variable value evaluated in the switch is
a string, that case is picked.
Reproduce code:
---------------
$var = "hello";
switch($var){
case 0:
echo "var is 0";
break;
default:
echo "default!";
}
Expected result:
----------------
default!
Actual result:
--------------
var is 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35188&edit=1