Questions & AnswersCategory: PHPHow to increase maximum execution time in PHP?
Gowri Shankar Staff asked 5 months ago

How to increase maximum execution time in PHP?

To prevent the PHP script from timing out in run time, we need to increase the execution time of the specific processing PHP script. By default, the maximum execution time for PHP scripts is 30 seconds as per configuration. Of course, it’s customizable based on our needs. Here’s how we can adjust it.

In PHP script

Place this line at the extreme top of your PHP script.

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

or

ini_set('max_execution_time', 0); //0 seconds = for infinite time of execution 

In .htaccess file

If you don’t have administrator access to your system but still want to set the option to all your scripts in your project folder.

Add the following lines to the .htaccess file within your PHP project folder, and this will be applied to all the scripts within that folder.

php_value max_execution_time 300

or

php_value max_execution_time 0

 

 

 

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.