+ 1

Break statement

Please explain me why can't I use break in this case? if(isset($_POST["email"])){ $email = addslashes($_POST["email"]); } elseif(empty($_POST["email"])){ $email = " "; break; } What's wrong in this code. It says: Fatal error: Cannot break/continue 1 level in D:\.....\.....\..... on line 111

2nd Apr 2017, 5:03 PM
Ani Naslyan
Ani Naslyan - avatar
4 Answers
+ 2
break statement is only used for loops
2nd Apr 2017, 5:04 PM
Edward
+ 2
the if else statement is not a loop
2nd Apr 2017, 5:04 PM
Edward
+ 1
And how can I miss that step instead of using 'break'?
2nd Apr 2017, 5:06 PM
Ani Naslyan
Ani Naslyan - avatar
0
You don't need any break statement in if statements. If one of the conditions is filled, then the program will automatically go out of the if statement.
4th Sep 2017, 10:49 PM
Bupatrick Publim
Bupatrick Publim - avatar