ID: 15010 User updated by: [EMAIL PROTECTED] Old Summary: switch() problem: "+" matches "-" Reported By: [EMAIL PROTECTED] Status: Open Bug Type: Variables related Operating System: RISC OS PHP Version: 4.1.0 New Comment:
Oh, I just assumed it was a problem with PHP, but if it doesn't happen on anything else, obviously not. :) I'll get in touch with the RISC OS porter. Previous Comments: ------------------------------------------------------------------------ [2002-01-12 18:29:33] [EMAIL PROTECTED] Ok, sorry. I misread your report a bit ;) So this applies only to RISC OS ? Can't reproduce this under linux. ------------------------------------------------------------------------ [2002-01-12 18:27:01] [EMAIL PROTECTED] Jesus man. case statements not followed by a break; statement fall through. Your code should read: <? $k = "+"; switch($k) { case "-": print "Oh no!"; break; case "+": print "Correct!"; break; } ?> ------------------------------------------------------------------------ [2002-01-12 18:21:28] [EMAIL PROTECTED] <? $k = "+"; switch($k) { case "-": print "Oh no!"; case "+": print "Correct!"; } ?> outputs "Oh no!". I guess this is because as switch uses ==, + and - are both being automatically converted to the number 0 which then matches? Could switch() perhaps use === instead of == in its comparison? ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=15010&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]