#41498 [Opn->Bgs]: switch..case output error
| From: | johannes@php.net | Date: | Fri, 25 May 2007 16:14:07 +0000 |
| Subject: | #41498 [Opn->Bgs]: switch..case output error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-113023@lists.php.net to get a copy of this message | ||
ID: 41498
Updated by: johannes@php.net
Reported By: eg dot soft at msa dot hinet dot net
-Status: Open
+Status: Bogus
Bug Type: Output Control
Operating System: windows xp
PHP Version: 5.2.2
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2007-05-25 16:12:20] crestfresh at gmail dot com
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."
------------------------------------------------------------------------
[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