Home >Backend Development >PHP Problem >How to set running time in php

How to set running time in php

尚
Original
2019-12-12 14:23:034673browse

How to set running time in php

Generally speaking, the default maximum execution time of a PHP program is 30 seconds. If your program exceeds this time limit, an error message similar to Maximum execution time of 30 seconds exceeded will appear.

There are several solutions:

First check whether you are doing something stupid, which consumes a lot of CPU resources and time. If it really requires the program to run for a long time to get the result If the result is generated, you can

1> Increase the running time in php.ini:

max_execution_time=300

2> Add the following code in the PHP file

ini_set('max_execution_time', 300); //300 seconds = 5 minutes

3> Use .htaccess file to increase running time:

<IfModule mod_php5.c>
    php_value max_execution_time 300
</IfModule>

Some other common configuration references:

<IfModule mod_php5.c>
    php_value post_max_size 5M
    php_value upload_max_filesize 5M
    php_value memory_limit 128M
    php_value max_execution_time 300
    php_value max_input_time 300
    php_value session.gc_maxlifetime 1200
</IfModule>

If your environment is wordpress, then in config.php, add:

define(&#39;WP_MEMORY_LIMIT&#39;, &#39;128M&#39;);

Recommended related articles and tutorials: php tutorial

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