How to Increase PHP Script Execution Time

Default maximum PHP Script Execution Time is 30 seconds, But if you need to process big file then you may have seen your script got crashed, and It throws script execution timeout error. So if your project required to process huge file like exporting big CSV file from MYSql, Then you need to increase PHP Script Execution Time, You can easily increase script execution time by following two ways.

By php.ini file

Open php.ini file in any text editor and find following line max_execution_time and edit it’s value.

max_execution_time = 300 // 300 seconds = 5 minutes


Add following code on the top of the page, Where long process need to execute.

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

Posted in PHP