note 13706 deleted from control-structures.switch by cmb
| From: | cmb@php.net | Date: | Sun, 21 Apr 2019 11:50:18 +0000 |
| Subject: | note 13706 deleted from control-structures.switch by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210641@lists.php.net to get a copy of this message | ||
Note Submitter: bensphpnetemail at supernaut dot org
----
It's obvious, but might still bear explicit mention that you can conditionally execute the
BREAK statement in order to allow a CASE to fall through to the next CASE.
e.g.:-> Here, CASE 1 will fall through and the DEFAULT CASE statements will also be executed
unless $somevar is true.
<?php
switch ($i) {
case 0:
print "i equals 0";
break;
case 1:
print "i equals 1";
if ($somevar) {
break;
}
default;
echo 'Some Default Statements';
break;
}
?>
Cheers,
Ben Nardone