note 46792 deleted from control-structures.switch by peehaa

From: Date: Mon, 02 Dec 2013 09:16:11 +0000
Subject: note 46792 deleted from control-structures.switch by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197703@lists.php.net to get a copy of this message
Note Submitter: pentek_imre at mailbox dot hu ---- Using select is like using == (instead of ===) in an if statement. Let's see an example: <?php function Describe($Q) { var_dump($Q); echo ": "; switch ($Q) { case "0": echo "String zero"; break; case 0: echo "Integer zero"; break; case NULL: echo "NULL NULL"; break; case FALSE: echo "Boolean FALSE"; break; case "": echo "Empty string"; break; default: echo "Any other value"; break; } echo "<BR>\n"; } Describe("0"); Describe(0); Describe(NULL); Describe(FALSE); Describe(""); Describe(1); ?> Output (PHP 5.0.1) is: string(1) "0" : String zero int(0) : String zero NULL : Integer zero bool(false) : String zero string(0) "" : Integer zero int(1) : Any other value

« previous php.notes (#197703) next »