ID: 47499
User updated by: mpb dot mail at gmail dot com
Reported By: mpb dot mail at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: Linux
PHP Version: 5.2.8
New Comment:
Ah. You are right. PHP is a crazy language.
Previous Comments:
------------------------------------------------------------------------
[2009-02-25 00:56:48] crrodriguez at opensuse dot org
$x is an integer, and 'foo' is a string in the first case..which gets
casted to an integer so it can be compared... it is the expected
behavior...
------------------------------------------------------------------------
[2009-02-25 00:16:12] mpb dot mail at gmail dot com
Description:
------------
When switching on 0 (zero), control flow executes the wrong case.
Reproduce code:
---------------
<?php
$x = 0;
switch ($x) {
case 'foo':
print "foo == $x ?\n";
break;
case 0:
print "0 == $x ?\n";
break;
default:
print "default: \$x == $x ?\n";
break; }
?>
Expected result:
----------------
0 == 0 ?
Actual result:
--------------
foo == 0 ?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47499&edit=1