If you’re writing a website in PHP, then by each PHP script will time out after a set time (usually 30 seconds by default). If this happen, you’ll see an error like the following:

Fatal error: Maximum execution time of 30 seconds exceeded in <file> on line <line>

This is a safety feature; if your code has an infinite loop or is waiting on a resource which will never become available, the script will be killed after this time limit. But what if you want a script to run longer than that? Simple – increase the time limit.


time is the amount of time you want to allow the script to run before timing out, in seconds. Put this at the top of your script before any other code. If you want to remove the time limit, set time to zero.