free stats

How to Increase the PHP Script Execution Time

Last Update : 16 Dec, 2022 How to Guide in PHP

In this article, you will learn to increase the PHP script execution time.

The default maximum execution time of each PHP script is 30 seconds.

But, When you are doing some PHP projects, need to execute a large script which took a long time. That time, you have to face the PHP timeout. 

To overcome this PHP timeout, You need to increase the execution time of the PHP script. You can increase the execution time by using php.ini file or PHP script.


Increase the execution time using PHP script

You can add the following PHP code line on the top of the script to increase the execution time.

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


Increase PHP script execution time using php.ini file

Here, you need to change the max_execution_time value of the php.ini file for increasing the PHP script execution time using the following steps.

  • Find and open the php.ini file.
  • Open the php.ini file in a text editor.
  • Search for the max_execution_time variable.
  • Change execution time (in seconds).
// 300 seconds = 5 minutes
max_execution_time = 300


You found this tutorial / article valuable? Need to show your appreciation? Here are some options:

01. Spread the word! Use following buttons to share this tutorial / article link on your favorite social media sites.

02. Follow us on Twitter, GitHub ,and Facebook.