Increase PHP Script Execution Time Limit

Today I would like to show you increasing PHP script execution time limit using ini_set() function. PHP default script execution limit is 30 seconds.

In my recent project to prevent the script from timing out, I had to set the PHP script execution time directly from with in the php file. So to execute my script more then 30 second I added below shown line at top of my file(first line).

This will set to 5 minutes time limit:

set_time_limit() has advantage, you can call it several times and it adds the time to the total script run-time. so you can use it in a loop and it doesn’t matter how many iterations you have, you set only the time per iteration.

The function set_time_limit(seconds) does exactly the same. If seconds is set to zero, no time limit is imposed.

This will set to no time limit:

If you have access to your php.ini file you can also configure execution time by changing following to something suitable to your requirement.

It is important to be careful using this on a production server. If you allow a script to run too long you could use all your servers resources and your website may go down.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
DMCA.com Protection Status
0
Would love your thoughts, please comment.x
()
x