What is the best setting for php script execution time?

怪我咯
Release: 2023-03-10 19:02:02
Original
1903 people have browsed it

Three methods for PHP to set the maximum execution time of a script

The default maximum execution time in php.ini is 30 seconds, which is determined by max_execution_time in php.ini Variable Specify that if the script needs to run for a long time, such as sending a large number of emails, or analyzing a large amount of data, the server will forcibly terminate the executing program after 30 seconds. In this case, the maximum execution time of the PHP script must be changed.

Three ways to set the maximum execution time of a script in PHP

1. Set it in php.ini

max_execution_time = 120;
Copy after login

2. Through PHPini_setFunctionSet

ini_set("max_execution_time", "120");
Copy after login

3. Set

through the

set_time_limit

function. If the above numbers are set to 0, there will be no limit. The script will continue to execute until the execution ends.

So, for scripts that need to be executed for a long time, generally just add the following code at the beginning of the php code

set_time_limit(0);
Copy after login


The above is the detailed content of What is the best setting for php script execution time?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template