Web Hosting Talk







View Full Version : exit and die


colossus
08-10-2004, 06:20 PM
I have a huge php page with a bunch of loops. If i say if blah=0 exit("blah is equal to zero");
The PHP will stop processing right?

Rich2k
08-10-2004, 06:29 PM
If you use a for loop and you reach the condition then yes it will break.

However if you really want to dump out of a loop simply use

break;

exit will terminate that script where the exit is, break will drop out of the current loop and carry on processing any code below it.

colossus
08-10-2004, 07:06 PM
exit is what i want and break is what i was confusing it with :). I want to terminate the script entirely where the exit is. Thanks.

JimPanse
08-10-2004, 07:29 PM
exit will break the scriptexecution immediately.

break; just breaks the current loop your still in and the script goes ahead.

if youd like to make some things "clear" b4 your script will "exit or die" you could use register_shutdown_function(); then