Alex Rivera | Logout

Can a PHP script abort itself or detect abortion?

Asked 2009-09-15T17:22:59.680
10

PHP scripts can continue executing after the HTTP page request, so how do I finally stop it executing when I'm done with it?

Also, is there an event to detect when the OS is going to forcibly abort the script? or how do I keep an internal timer to predict max_execution_time?

Edit
Report

1 Answer

5

You can use register_shutdown_function to register a function to be called at the end of script execution. You can use this to detect when the script has been terminated and perform a certain set of actions.

answered 2009-09-15T17:33:56.757

Your Answer