Home  >  Article  >  Backend Development  >  Solution to PHP script execution timeout

Solution to PHP script execution timeout

WBOY
WBOYOriginal
2016-08-08 09:32:091354browse

PHP's default script execution timeout is 30 seconds, which is specified by the max_execution_time variable in php.ini. The server will forcibly terminate the executing program after 30 seconds. If you want to finish executing a script that takes more than 30 seconds, you can use the following steps One way to solve this problem:
Modify the script execution time limit of php.ini

Edit php.ini and modify the max_execution_time value:
max_execution_time=500
//This modification requires reloading php.ini and restarting the web server to take effect.

Set the script execution time through the .htaccess file
php_value max_execution_time 500

Set the maximum execution time in the script
ini_set('max_execution_time', 500);

Use the php function to cancel the time limit of the script
set_time_limit (0);
set_time_limit is used to set the timeout of the script. This function stipulates that the program must run to completion within the specified number of seconds from the time the sentence is run. If the timeout expires, the program will exit with an error.
Usage: set_time_limit(seconds);
//When the number of seconds is 0, it indicates that the script has no time limit.

The above introduces the solution to the PHP script execution timeout, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

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