note 105372 deleted from control-structures.break by danbrown
| From: | danbrown@php.net | Date: | Fri, 12 Aug 2011 15:33:32 +0000 |
| Subject: | note 105372 deleted from control-structures.break by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182449@lists.php.net to get a copy of this message | ||
Note Submitter: AlanHamilton at pobox dot com
----
@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.
<<<