note 87959 added to control-structures.switch
| From: | hamiltont at gmail dot com | Date: | Fri, 02 Jan 2009 19:32:45 +0000 |
| Subject: | note 87959 added to control-structures.switch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148760@lists.php.net to get a copy of this message | ||
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
----
Server IP: 64.71.164.2
Probable Submitter: 129.59.156.38
----
Manual Page -- http://www.php.net/manual/en/control-structures.switch.php
Edit -- https://master.php.net/note/edit/87959
Del: integrated -- https://master.php.net/note/delete/87959/integrated
Del: useless -- https://master.php.net/note/delete/87959/useless
Del: bad code -- https://master.php.net/note/delete/87959/bad+code
Del: spam -- https://master.php.net/note/delete/87959/spam
Del: non-english -- https://master.php.net/note/delete/87959/non-english
Del: in docs -- https://master.php.net/note/delete/87959/in+docs
Del: other reasons-- https://master.php.net/note/delete/87959
Reject -- https://master.php.net/note/reject/87959
Search -- https://master.php.net/manage/user-notes.php