note 87959 deleted from control-structures.switch by crell
| From: | crell@php.net | Date: | Mon, 27 Jun 2022 20:57:28 +0000 |
| Subject: | note 87959 deleted from control-structures.switch by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218638@lists.php.net to get a copy of this message | ||
Note Submitter: hamiltont at gmail dot com
----
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