tags:

views:

139

answers:

3

When exit() is executed,trigger another procedure,is there an easy way?

+6  A: 

exit() terminates the execution of the script -- so, there is not much than can be done after it's been called.


Still, quoting the manual :

Shutdown functions and object destructors will always be executed even if exit() is called.


So, you cannot "trigger another procedure" when exit() is called -- but you can register a function that will be called each time the PHP script ends ; including the times when it's being terminated because of a call to exit().

Pascal MARTIN
I found `lime_test` can do this,but don't know they approaches it.
I suppose it's using a shutdown function *(or some object destructor)* ;-)
Pascal MARTIN
I just tried,the `__destruct` won't be called when `exit()`
+1  A: 

When exit is called, you'll still trigger any registered shutdown functions. You can use that to "catch" any calls to exit.

Alan Storm
A: 

Try looking at runkit, maybe it will help you.

Shein Alexey