View Full Version : Command for stopping PHP dead

08-11-2007, 07:57 PM
Is there a simple command that will stop PHP executing in it's tracks? I'm writing a fairly complex script with many nested loops, and at some point if a condition is met I'd like the script to stop and output some HTML without executing the tail end of the loops.

Something like break() but for if/else loops, basically.

08-11-2007, 10:23 PM
Stop forever, or just exit the if/else loop?

To stop the script forever, use die() or exit().


08-12-2007, 12:02 AM
What whizard said -- To stop the script - just use this:

if($statement == $statement){
echo "You failed to meet the requirements."; exit;
}elseif($statement == $statement){
die("You failed to meet the requirements.");
echo "";

08-12-2007, 01:29 AM
Heh, I like how I virtually answered my own question. "Stop PHP dead" indeed...

die() of course is right in front of my nose virtually all the time :-).

08-12-2007, 04:22 AM
LOL. Haha. =p