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

How to set running time in php

Release: 2023-02-28 17:24:02
Original
4675 people have browsed it

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
Copy after login

2> Add the following code in the PHP file

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

3> Use .htaccess file to increase running time:

<IfModule mod_php5.c>
    php_value max_execution_time 300
</IfModule>
Copy after login

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>
Copy after login

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

define(&#39;WP_MEMORY_LIMIT&#39;, &#39;128M&#39;);
Copy after login

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!

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