|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-06-16 18:12 UTC] chealer at gmail dot com
Description: ------------ --- From manual page: http://www.php.net/control-structures.break --- "break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of." The documentation does not specify what happens if break's optional is not provided. Therefore, the effect of a "break;" statement inside several concerned structures (as happens at the end of the example) is unspecified. As of PHP 5.4, the effect appears to be that of "break 1;". Comment http://php.net/manual/en/control-structures.break.php#90308 confirms. Test script: --------------- <?php foreach(array(1, 2) as $iteration) { var_dump($iteration); foreach (array() as $dummy) { break; } } ?> Actual result: -------------- int 1 int 2 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 11:00:02 2026 UTC |
Apologies, the result is the same, but the proper test should have read: <?php foreach(array(1, 2) as $iteration) { var_dump($iteration); foreach (array(1) as $dummy) { break; } } ?>