user198729
user198729

Reputation: 63626

How to catch the exit() event in PHP?

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

Upvotes: 8

Views: 7619

Answers (3)

Aleksey Shein
Aleksey Shein

Reputation: 7482

Try looking at runkit, maybe it will help you.

Upvotes: -2

Alana Storm
Alana Storm

Reputation: 166046

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

Upvotes: 6

Pascal MARTIN
Pascal MARTIN

Reputation: 400912

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().

Upvotes: 9

Related Questions