Home > Backend Development > PHP Problem > How to modify the maximum time in php

How to modify the maximum time in php

藏色散人
Release: 2023-03-14 18:50:01
Original
2304 people have browsed it

Methods to modify the maximum time in php: 1. Set "max_execution_time = 120;" in php.ini; 2. Set it through PHP's ini_set function; 3. Set it through the set_time_limit function.

How to modify the maximum time in php

#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.

How to modify the maximum time in php?

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 php The max_execution_time variable in .ini specifies 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 PHP script must be changed. Maximum execution time.

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. Set it through PHP's ini_set function

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

3. Set through the set_time_limit function

set_time_limit(120);
Copy after login

If the above numbers are set to 0, there will be no limit, and the script will continue to execute until the end of execution.

Therefore, for scripts that need to be executed for a long time, generally add the following code at the beginning of the PHP code

set_time_limit(0);
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to modify the maximum time in php. 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