note 85439 added to control-structures.break
| From: | Coryf88 at hotmail dot com | Date: | Sat, 30 Aug 2008 20:51:42 +0000 |
| Subject: | note 85439 added to control-structures.break | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144018@lists.php.net to get a copy of this message | ||
Breaks are not required within a switch, they simply break the switch from being further processed.
<?php
$total = 0;
switch($i) {
case 6:
$total = 99;
break;
case 1:
$total += 1;
case 2:
$total += 2;
case 3:
$total += 3;
case 4:
$total += 4;
case 5:
$total += 5;
}
?>
Using the above snippet, all of the following would be true:
If $i = 6, $total would = 99.
If $i = 5, $total would = 5.
If $i = 4, $total would = 9.
If $i = 3, $total would = 12.
If $i = 2, $total would = 14.
If $i = 1, $total would = 15.
----
Server IP: 208.69.120.35
Probable Submitter: 69.66.192.192
----
Manual Page -- http://www.php.net/manual/en/control-structures.break.php
Edit -- https://master.php.net/note/edit/85439
Del: integrated -- https://master.php.net/note/delete/85439/integrated
Del: useless -- https://master.php.net/note/delete/85439/useless
Del: bad code -- https://master.php.net/note/delete/85439/bad+code
Del: spam -- https://master.php.net/note/delete/85439/spam
Del: non-english -- https://master.php.net/note/delete/85439/non-english
Del: in docs -- https://master.php.net/note/delete/85439/in+docs
Del: other reasons-- https://master.php.net/note/delete/85439
Reject -- https://master.php.net/note/reject/85439
Search -- https://master.php.net/manage/user-notes.php