Hey :) I'm trying to exit from an 'if' loop but i cant find the right way to do it. I've heard of 'break' but this is only for while, for, foreach, switch etc etc. not 'if'. Can anyone please help??
Many thanks, BIOSTALL
Printable View
Hey :) I'm trying to exit from an 'if' loop but i cant find the right way to do it. I've heard of 'break' but this is only for while, for, foreach, switch etc etc. not 'if'. Can anyone please help??
Many thanks, BIOSTALL
You cannot break out of an IF statement. What you can do though is enclose the IF statement inside a function and use return to escape from it.
IF is not even a loop.
However, when I have a block where I sometimes prematurely have to jump to the end, I sometimes do this:
Code:do {
...
...
...
// Uh-oh, need to jump
if($total_disaster) break;
...
...
} while(false);