...

View Full Version : Command for stopping PHP dead



Pennimus
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.

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

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

HTH
Dan

thiscolddecembe
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.");
}else{
echo "";
}

Pennimus
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 :-).

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum