#20780 [Opn->Bgs]: switch ... case ... statement cannot distinguish a string with integer 0
| From: | chregu@php.net | Date: | Tue, 03 Dec 2002 07:16:39 +0000 |
| Subject: | #20780 [Opn->Bgs]: switch ... case ... statement cannot distinguish a string with integer 0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-26467@lists.php.net to get a copy of this message | ||
ID: 20780
Updated by: chregu@php.net
Reported By: rosewell@cnk.com.cn
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows 2000
PHP Version: 4.2.3
New Comment:
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.
Thank you for your interest in PHP.
See
http://ch.php.net/manual/en/language.types.string.php#language.types.string.conversion
Previous Comments:
------------------------------------------------------------------------
[2002-12-02 23:54:45] rosewell@cnk.com.cn
<?php
$a = 'center';
switch ($a) {
case 'left':
case 0: echo 'left';break;
case 'right':
case 2: echo 'right';break;
default:echo 'center';
}
?>
The script should generate 'center',yet generate 'left';what's more,any
string assigned to variable $a will generate the same error. The reason
is the PHP scripting engine cannot distinguish a string with integer 0.
I wonder if the switch statement can only be applied on integers.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20780&edit=1