Bug #16843 Updated: Switch fails when variable being switched equals zero

From: Date: Fri, 26 Apr 2002 08:29:30 +0000
Subject: Bug #16843 Updated: Switch fails when variable being switched equals zero
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-6075@lists.php.net to get a copy of this message
ID: 16843 Updated by: yohgaki@php.net Reported By: matrix@matrixscripts.com Status: Bogus Bug Type: Variables related Operating System: Red Hat Linux PHP Version: 4.2.0 New Comment: Should we better to consider change automatic message to be more polite? (or mention that it's a auto generate message?) I'm not native English speaker, so I cannot tell if we need it ;) Yasuo Previous Comments: ------------------------------------------------------------------------ [2002-04-26 03:40:43] matrix@matrixscripts.com Alright, I understand what you are all saying. I'm sorry if my most recent comment sounded rude - I was annoyed that yohgaki@php.net thought I would be foolish enough to ask a support question here. I genuinely thought this was a bug. One question that's still at the back of my mind is, why does it work for everything else, except when it's being compared to 0? ------------------------------------------------------------------------ [2002-04-26 03:34:53] derick@php.net Your code is bogus, this is correct: $filled = 0; switch ($filled) { case 0: echo "filled equals zero"; break; } Who told you you can use case $filled == 0: ? It's simply not ok. ------------------------------------------------------------------------ [2002-04-26 03:32:38] rasmus@php.net What makes you think you can put expressions in a case statement? You can't. No bug here. ------------------------------------------------------------------------ [2002-04-26 03:29:17] matrix@matrixscripts.com Perhaps you misunderstood my report - what I posted SHOULD echo "filled equals zerofilled equals zero also" but it doesn't. Another example below: $filled = 0; switch($filled){ case $filled == 0: echo "filled equals 0" break; } $filled = 100; switch($filled){ case $filled == 100: echo "filled equals 100" break; } When that is executed, it returns "filled equals 100". It SHOULD have returned "filled equals 0filled equals 100" but it doesn't - the only explanation is a bug in the switch code. This is not a bogus bug report. ------------------------------------------------------------------------ [2002-04-26 03:18:11] yohgaki@php.net The bug system is not the appropriate forum for asking support questions. For a list of a range of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/16843 -- Edit this bug report at http://bugs.php.net/?id=16843&edit=1

« previous php.bugs (#6075) next »