search
HomeBackend DevelopmentPHP ProblemHow to modify php script execution time

3 methods: 1. Open the "php.ini" file and modify the value of the "max_execution_time" item. 2. Use "ini_set("max_execution_time", "new value");" to modify. 3. Use "set_time_limit(new value);" to modify.

How to modify php script execution time

The operating environment of this tutorial: Windows 7 system, PHP version 7.1, DELL G3 computer

The php script execution time involves whether the script runs out of time. The maximum execution time of php script is 30 seconds.

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, to prevent the server from forcibly stopping the executing program after 30 seconds, in this case, the maximum value of the PHP script must be changed. execution time.

So how to modify the php script execution time?

The following are 3 methods:

1. Set in php.ini

In the php.ini configuration file , the script execution time is specified by the max_execution_time variable. Therefore, you only need to set the value of the variable

max_execution_time = 新数值;

2. Set it through PHP's ini_set function

ini_set is used to set the value of php.ini. When the function is executed It takes effect when the script ends. After the script ends, the setting becomes invalid. You can modify the configuration without opening the php.ini file, which is very convenient for virtual spaces.

You only need to use the ini_set function to modify the value of the max_execution_time variable

ini_set("max_execution_time", "新数值");

3. Set through the set_time_limit function

The set_time_limit function is used to limit pages

set_time_limit(新数值);

Explanation of execution time:

Among the above 3 methods, if the value is set to 0, there is 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);

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to modify php script execution time. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use