How to catch the exit() event in PHP?

events, php

Solution

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

Problem

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

Original source