exit not working

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
This either just started happening on PHP 5 or I never noticed the
errors in the error logs before.

In an if construct, if a certain condition is present, I want to exit
the entire script, so after printing something to the screen I issue
the exit; command. However, in the error logs, it shows that the script
continues out of the if construct and hits the next line which uses
list/explode, but this causes errors because the variables are not

The bottom line is why does the script continue after exit? I've even
taken the exit command out of the if construct and put it directly
above the list/explode statement, so that regardless of any condition
the script should end...yet it still continues.

I've tried exit;, exit();, and die(); all with the same results.

Anyone have any ideas how to get around this?


Re: exit not working


Quoted text here. Click to load it

i had similar trouble on a shared hosting server - script continuing when i  
clearly told it to exit.  

i think it involves something with either safe_mode being enabled, output  
buffering being enabled, or error_reporting being enabled.

it makes debugging sheer hell.  someone else can probably tell you what it  
is specifically, but i encountered this problem last week (on PHP 4 btw).

good luck

Re: exit not working

Good Man wrote:
Quoted text here. Click to load it

Have a look at trigger_error:  

I nowadays use something along the lines of the below if I want a hard  
exit (and depending on your error level settings this can be shown to  
the user / logged or you can use set_error_handler to specify a totally  
different action:

trigger_error('error message', E_USER_ERROR );

Site Timeline