note 129668 added to control-structures.break
| From: | cedricj54@nospam.io | Date: | Wed, 24 Jul 2024 11:59:31 +0000 |
| Subject: | note 129668 added to control-structures.break | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221440@lists.php.net to get a copy of this message | ||
@ei dot dwaps at gmail dot com
To break more than 2 levels you must have more than 2 structure.
In your example you have 2 structures : while and foreach and you try to break three.
Test with 3 structures and it works ;), example with adding for loop :
<?php
for ($i = 0; $i > 5; ++$i) {
while (true) {
foreach ([1, 2, 3] as $value) {
echo 'ok<br>';
break 3; // Fatal error: Cannot 'break' 3 levels
}
echo 'jamais exécuter';
break;
}
}
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 46.235.153.156)
----
Manual Page -- https://php.net/manual/en/control-structures.break.php
Edit -- https://main.php.net/note/edit/129668
Del: integrated -- https://main.php.net/note/delete/129668/integrated
Del: useless -- https://main.php.net/note/delete/129668/useless
Del: bad code -- https://main.php.net/note/delete/129668/bad+code
Del: spam -- https://main.php.net/note/delete/129668/spam
Del: non-english -- https://main.php.net/note/delete/129668/non-english
Del: in docs -- https://main.php.net/note/delete/129668/in+docs
Del: other reasons-- https://main.php.net/note/delete/129668
Reject -- https://main.php.net/note/reject/129668
Search -- https://main.php.net/manage/user-notes.php