note 82461 deleted from control-structures.switch by peehaa

From: Date: Mon, 02 Dec 2013 09:04:00 +0000
Subject: note 82461 deleted from control-structures.switch by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197689@lists.php.net to get a copy of this message
Note Submitter: jphansen at uga dot edu ---- An easy mistake some programmers from other languages might make is delimiting conditions for a case block by a comma: <? $val = "x"; switch ($val) { case "x", "y", "z": echo "Case is x, y or z"; break; } ?> Instead, in PHP this is accomplished by using the "case" identifier for each condition: <? $val = "x"; switch ($val) { case "x": case "y": case "z": echo "Case is x, y or z"; break; } ?>

« previous php.notes (#197689) next »