note 30622 added to control-structures.switch

From: Date: Mon, 24 Mar 2003 08:51:53 +0000
Subject: note 30622 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-45719@lists.php.net to get a copy of this message
It should be pointed out that this: <?php $var = 0; switch ( $var ) { case "something": $foo = "Broken"; break; default: $foo = "Okay"; break; } echo $foo; ?> Will print out "Broken". It's not broken, because in PHP, when an Integer and a String are compared, the string is == 0. So 0 == "something". However, this is not apparent. switch() does not do type checking. -- http://www.php.net/manual/en/control-structures.switch.php http://master.php.net/manage/user-notes.php?action=edit+30622 http://master.php.net/manage/user-notes.php?action=delete+30622 http://master.php.net/manage/user-notes.php?action=reject+30622

« previous php.notes (#45719) next »