note 60226 deleted from control-structures.break by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:53:38 +0000 |
| Subject: | note 60226 deleted from control-structures.break by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215365@lists.php.net to get a copy of this message | ||
Note Submitter: traxer at gmx dot net
----
vlad at vlad dot neosurge dot net wrote on 04-Jan-2003 04:21
> Just an insignificant side not: Like in C/C++, it's not
> necessary to break out of the default part of a switch
> statement in PHP.
It's not necessary to break out of any case of a switch statement in PHP, but if you want only
one case to be executed, you have do break out of it (even out of the default case).
Consider this:
<?php
$a = 'Apple';
switch ($a) {
default:
echo '$a is not an orange<br>';
case 'Orange':
echo '$a is an orange';
}
?>
This prints (in PHP 5.0.4 on MS-Windows):
$a is not an orange
$a is an orange
Note that the PHP documentation does not state the default part must be the last case statement.