Home > Backend Development > PHP Tutorial > PHP execution time function ini_set and max_execution_time

PHP execution time function ini_set and max_execution_time

WBOY
Release: 2016-07-25 08:54:20
Original
1798 people have browsed it
Introduce the usage of the execution time functions ini_set and max_execution_time in PHP. Friends in need can refer to it.

The default maximum execution time in php.ini is 30 seconds, which is specified by the max_execution_time variable in php.ini. If it takes a long time to complete the work, such as sending many emails to a large number of recipients, Or perform heavy data analysis work, the server will forcibly terminate the executing program after 30 seconds. There is actually a solution to this problem.

The simplest method is to modify the value of max_execution_time in php.ini. However, not everyone has the right to modify php.ini. For example, developers who use web hosting. The php.ini on the server is used by many websites, so it cannot be modified at will. Revise.

Another way is to add ini_set('max_execution_time', '0') or set_time_limit('0') to the header of the PHP program. A value of 0 means there is no execution time limit, and your program can run as long as it needs to. If your program is still in the testing stage, it is recommended that you set the time limit to a real number to prevent program errors from crashing the server.



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