note 87959 modified in control-structures.switch by felipe

From: Date: Sat, 17 Jan 2009 01:29:36 +0000
Subject: note 87959 modified in control-structures.switch by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149358@lists.php.net to get a copy of this message
Example of default NOT included as the last item <?php switch(5) { case 1: echo "1"; break; case 2: default: echo "2, default"; break; case 3; echo "3"; break; } ?> Outputs '2,default' very useful if you want your cases to be presented in a logical order in the code (as in, not saying case 1, case 3, case 2/default) and your cases are very long so you do not want to repeat the entire case code at the bottom for the default Hamy --was-- Example of default NOT included as the last item switch(5) { case 1: echo "1"; break; case 2: default: echo "2, default"; break; case 3; echo "3"; break; } Outputs '2,default' very useful if you want your cases to be presented in a logical order in the code (as in, not saying case 1, case 3, case 2/default) and your cases are very long so you do not want to repeat the entire case code at the bottom for the default Hamy http://php.net/manual/en/control-structures.switch.php

« previous php.notes (#149358) next »