Get the App
SLTechnology News&Howtos  ›  Development  › 

How to modify the maximum time of php

Shulou Source: shulou.com Published: 2022-06-02 03:40:07 11月03日 Update

In this article, the editor introduces in detail "how to modify the maximum time of php", the content is detailed, the steps are clear, and the details are handled properly. I hope that this "how to modify the maximum time of php" article can help you solve your doubts.

The method to modify the maximum time of php: 1, set "max_execution_time = 120;" in php.ini; 2, set through the ini_set function of PHP; 3, set it through the set_time_limit function.

This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer.

How to modify the maximum time of php?

Three methods of setting the maximum execution time of script by PHP

The default maximum execution time in php.ini is 30 seconds, which is specified by the max_execution_time variable in php.ini. 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 abort the executing program after 30 seconds. In this case, you have to change the maximum execution time of the php script.

Three methods of setting the maximum execution time of script by PHP

1. Set it in php.ini

Max_execution_time = 120

2. Set it through the ini_set function of PHP

Ini_set ("max_execution_time", "120")

3. Set through the set_time_limit function

Set_time_limit (120)

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

Therefore, for scripts that need to be executed for a long time, you can usually add the following code at the beginning of the php code

Set_time_limit (0); read here, this article "how to modify the maximum time of php" article has been introduced, want to master the knowledge of this article still need to practice and use in order to understand, if you want to know more related articles, welcome to follow the industry information channel.

Tags: Time maximum script function article method code content long time proper longest variable beginning idea situation number data new knowledge unlimited is determined by Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Apple macOS MariaDB vpn