When exit()
is executed,trigger another procedure,is there an easy way?
The exit() function in PHP is an inbuilt function which is used to output a message and terminate the current script. The exit() function only terminates the execution of the script. The shutdown functions and object destructors will always be executed even if exit() function is called.
Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. The status 0 is used to terminate the program successfully.
The return keyword ends a function and, optionally, uses the result of an expression as the return value of the function. If return is used outside of a function, it stops PHP code in the file from running.
On many computer operating systems, a computer process terminates its execution by making an exit system call. More generally, an exit in a multithreading environment means that a thread of execution has stopped running. For resource management, the operating system reclaims resources (memory, files, etc.)
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()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With