This article mainly introduces the PHP function timeout processing method, and analyzes the timeout processing techniques based on register_shutdown_function in the form of instances, which has some reference value, for more information about how to handle PHP function timeout, see the following example. We will share this with you for your reference. The details are as follows:
Register_shutdown_function
Registers the function named by function to be executed when script processing is complete or when exit () is called.
This function can be registered repeatedly and then called in turn when a fatal error or exit occurs.
Error_reporting (0); register_shutdown_function ('handleshutdown'); function handleShutdown () {$ error = error_get_last (); // based on the error message, determine if the request times out if ($ error & strpos ($ error ['message'], 'maximum exec ')! = False) {echo 'handle time out';} set_time_limit (2); sleep (3 );