Reputation: 57966
I have just come across this code:
function test(){
//...
if ( $profilerule == "profile" and $operator != "=" ) {
verbatimlogit('false');
break;
}
//...
}
Is it just me or will that break not work there?! There isn't even a loop. A continue work either, right?
I just want a confirmation here as I am pretty sure this is the case.
Upvotes: 0
Views: 83
Reputation: 15453
What exactly are you trying to do?
If you're trying to end execution of the function, you'd probably just want to use the return() statement.
Upvotes: 2
Reputation: 99811
From the PHP Documentation:
break
ends execution of the currentfor
,foreach
,while
,do
-while
orswitch
structure.
So yes, inside an if
, it's invalid (unless that if
is within one of the above structures).
Upvotes: 2
Reputation: 75744
According to the PHP docs of the break
keyword, this would be an invalid structure (unless there was a loop in the code you removed.)
Upvotes: 4