When exit()
is executed,trigger another procedure,is there an easy way?
views:
139answers:
3
+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
2010-03-05 06:02:13
I found `lime_test` can do this,but don't know they approaches it.
2010-03-05 06:03:36
I suppose it's using a shutdown function *(or some object destructor)* ;-)
Pascal MARTIN
2010-03-05 06:05:10
I just tried,the `__destruct` won't be called when `exit()`
2010-03-05 06:28:56
+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
2010-03-05 06:03:46