Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to catch the exit() event in PHP?

Tags:

php

events

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

like image 562
user198729 Avatar asked Mar 05 '10 06:03

user198729


People also ask

What does exit () do in PHP?

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.

What does exit 0 do in PHP?

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.

Does Return exit the function PHP?

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.

What is exit execution?

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


1 Answers

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

like image 174
Pascal MARTIN Avatar answered Nov 09 '22 00:11

Pascal MARTIN