note 105372 added to control-structures.break
| From: | AlanHamilton at pobox dot com | Date: | Fri, 12 Aug 2011 14:13:41 +0000 |
| Subject: | note 105372 added to control-structures.break | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182444@lists.php.net to get a copy of this message | ||
@RK: This seems to behave like C:
After exiting all the nested for, foreach, while, do-while and switch structures, the enclosing
structure is the PHP program, so:
Breaks 1 through 8 took you out of the 8 nested control structures.
Break 9 took you out of the program.
Break 10 was not executed.
===
Perhaps the description should be updated to something like:
>>>
break ends execution of the current for, foreach, while, do-while, switch, or program control
structure.
Because break treats the PHP program as the outermost control structure, using break outside of any
of the other control structures exits the program.
break accepts an optional numeric argument which tells it how many nested enclosing structures are
to be broken out of.
Warning: If you use break with a numeric argument larger than the number of other nested control
structures, it exits the program.
<<<
----
Server IP: 69.147.83.197
Probable Submitter: 71.232.13.166
----
Manual Page -- http://www.php.net/manual/en/control-structures.break.php
Edit -- https://master.php.net/note/edit/105372
Del: integrated -- https://master.php.net/note/delete/105372/integrated
Del: useless -- https://master.php.net/note/delete/105372/useless
Del: bad code -- https://master.php.net/note/delete/105372/bad+code
Del: spam -- https://master.php.net/note/delete/105372/spam
Del: non-english -- https://master.php.net/note/delete/105372/non-english
Del: in docs -- https://master.php.net/note/delete/105372/in+docs
Del: other reasons-- https://master.php.net/note/delete/105372
Reject -- https://master.php.net/note/reject/105372
Search -- https://master.php.net/manage/user-notes.php