How to catch exit () event in PHP?

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

+4
source share
3 answers

exit() completes the execution of the script - so after creating it there is not as much as you could do.


However, quoting the manual:

The shutdown functions and the destructor object will always be executed, even if exit() called.


Thus, you cannot โ€œcall another procedureโ€ when exit() is called, but you can register a function that will be called every time the PHP script ends; including the time when it exits due to the call to exit() .

+8
source

When the call is called, you will still run any registered shutdown functions . You can use this to โ€œcatchโ€ any calls to exit.

+5
source

Try to find runkit , maybe this will help you.

-1
source

Source: https://habr.com/ru/post/1303202/


All Articles