Home >Backend Development >PHP Tutorial >PHP function timeout processing method, php timeout processing method_PHP tutorial

PHP function timeout processing method, php timeout processing method_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:59:22840browse

PHP function timeout processing method, php timeout processing method

The example in this article describes the PHP function timeout processing method. Share it with everyone 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 will be called sequentially. This function will be called when a fatal error or exit occurs

error_reporting(0);
register_shutdown_function ( 'handleShutdown' );
function handleShutdown (){
  $error = error_get_last ();
  // 根据错误信息,判断是否是超时了
  if ( $error && strpos ( $error [ 'message' ], 'Maximum exec' )!== false )
  {
    echo 'handle time out';
  }
}
set_time_limit(2);
sleep(3);

Readers who are interested in more PHP-related content can check out the special topics of this site: "Introduction Tutorial on PHP Basic Syntax", "Summary of PHP Error and Exception Handling Methods" and "Summary of Common PHP Functions and Techniques"

I hope this article will be helpful to everyone in PHP programming.

Articles you may be interested in:

  • PHP file_get_contents setting timeout processing method
  • In-depth explanation of the timeout processing method of PHP function file_get_contents
  • Several types in PHP Comprehensive summary of common timeout processing
  • Methods for PHP access MySQL query timeout processing
  • PHP include class file timeout problem processing
  • Processing (php-cgi.exe - FastCGI process exceeds (Configured request timeout)
  • Solution to php setting page timeout
  • Example of method to capture timeout event in PHP
  • Method to set timeout limit for php page function

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1099058.htmlTechArticlePHP function timeout processing method, php timeout processing method This article describes the PHP function timeout processing method in an example. Share it with everyone for your reference, the details are as follows: register_shutdown_function R...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn