note 40662 deleted from control-structures.break by nlopess
| From: | nlopess@php.net | Date: | Thu, 11 Mar 2004 14:58:43 +0000 |
| Subject: | note 40662 deleted from control-structures.break by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66654@lists.php.net to get a copy of this message | ||
Note Submitter: matt@mooseit.biz
----
In reply to vlad at vlad dot neosurge dot net, what you say is not entirely true. The default case
is not required to be at the end of the switch statement, and in this case you would be required to
break from the default case to prevent unexpected results. For example:
<?php
$a = 'foo';
switch($a) {
default:
echo "Blah1";
case 'bar':
echo "Blah2";
break;
}
?>
This example will return the string 'Blah1Blah2', whereas the expected result if default
case automatically broke would be 'Blah1'.