|
-
Sep 4th, 2005, 06:43 AM
#1
Thread Starter
Addicted Member
[RESOLVED] break from 'if' loop
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
-
Sep 4th, 2005, 06:54 AM
#2
Re: break from 'if' loop
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.
-
Sep 4th, 2005, 04:09 PM
#3
Re: [RESOLVED] break from 'if' loop
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);
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|