Fatal error: 'break' not in the 'loop' or 'switch' in context?

on line where break

if (isset($_SESSION['id'])) {
 if (isset($_POST['passwordEnter'])) {
 $id1 = $_SESSION['id'];
 if (!preg_match('/^(?=.*\d)(?=.*[A-Z])(?=.*[a-z])[0-9A-Za-z_]{8,}$/', $_POST['password'])) {
 echo "<script>alert('Not secure enough, The password must be minimum 8 characters and must contain lower case letter, upper case letter and number')</script>";
 elseif (htmlspecialchars($_POST['newPassword']) == htmlspecialchars($_POST['retypePassword'])) {
 $firebase->set(DEFAULT_PATH . "/ARCusers/$id1/password", htmlspecialchars($_POST['newPassword']));
} else {
June 14th 19 at 19:20
2 answers
June 14th 19 at 19:22
Well, the error itself speaks for itself O_O

break can be used within a loop or a switch construct.

If inside of a function or method can't return
If not - exit|die

But the logic is wrong if you have so perverted
June 14th 19 at 19:24
Good afternoon.
PHP 7.0 and above, the break statement is no longer allowed outside a for statement, foreach or switch and gives a fatal error.

Find more questions by tags PHP