note 40662 added to control-structures.break
| From: | matt at mooseit dot biz | Date: | Wed, 10 Mar 2004 23:15:47 +0000 |
| Subject: | note 40662 added to control-structures.break | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66586@lists.php.net to get a copy of this message | ||
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'.
----
Manual Page -- http://www.php.net/manual/en/control-structures.break.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40662
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40662&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40662&report=yes
Search -- http://master.php.net/manage/user-notes.php