ID: 41498 Comment by: crestfresh at gmail dot com Reported By: eg dot soft at msa dot hinet dot net Status: Open Bug Type: Output Control Operating System: windows xp PHP Version: 5.2.2 New Comment:
http://www.php.net/manual/en/language.operators.comparison.php "If you compare an integer with a string, the string is converted to a number. If you compare two numerical strings, they are compared as integers. These rules also apply to the switch statement." Previous Comments: ------------------------------------------------------------------------ [2007-05-25 13:43:32] eg dot soft at msa dot hinet dot net Description: ------------ $a = 'aa'; $b = 'bb'; $value = 0; switch ($value) { case $a: echo $a."\n"; break; case $b: echo $b."\n"; break; default: echo "default\n"; } ==> output: aa (Why?!) $a = 'aa'; $b = 'bb'; $value = 0; switch ($value) { case $b: echo $b."\n"; break; case $a: echo $a."\n"; break; default: echo "default\n"; } ==> output: bb (Why?!) Reproduce code: --------------- $a = 'aa'; $b = 'bb'; $value = 0; switch ($value) { case $a: echo $a."\n"; break; case $b: echo $b."\n"; break; default: echo "default\n"; } Expected result: ---------------- default Actual result: -------------- aa ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41498&edit=1
