How to increase maximum execution time in PHP and WordPress
We mostly see that the maximum execution time of a PHP Script is 30 seconds. If a script takes more than 30 seconds to execute, it will throw the following Fatal error. Fatal error: Maximum execution time of 30 seconds exceeded in ….
We can increase maximum execution time in PHP and WordPress by using various methods. In the following examples, we have increased maximum execution time to 360 seconds (6 minutes).
Method 1: By adding the code in a PHP
file:
We can set the maximum execution time by adding this code in a PHP File. You must add this code in that file which is included earlier in all other pages. Then this function will increase maximum execution time in all those files.
For example, put this code in the header (header.php), or configuration (config.php) if available.set_time_limit(360);
Method 2: Inside the .htaccess
file:
We can do the same thing inside the .htaccess
file as well. Before editing this file, you make sure to have a backup of .htaccess.
php_value max_execution_time 360
Method 3: Inside the php.ini
file:
We can also set the maximum execution time by adding this code in the php.ini
file.max_execution_time = 360
Method 4: Inside wp-config.php
file in WordPress:
If you are using WordPress then you can place this code in wp-config.php
file.set_time_limit(360);
Tutorials |
---|
No Content Found. |
Exercises & Assignments |
---|
No Content Found. |
Interview Questions & Answers |
---|
No Content Found. |