I have written a PHP code to do some processing on data, but before the processing can finish, the script throws an error ‘Fatal error: Maximum execution time of 30 seconds exceeded in /home/dales/public_html/processbulkdata.php’.
To change the maximum execution time of a PHP script you need to use the ‘
set_time_limit‘ function. The function takes one argument which is the maximum number of seconds a script is allowed to run. If seconds is set to ‘0′, no time limit is imposed on the script and it may run indefinitely. Use the following snippet just before your time consuming code begins:
Note that, if you set the number of seconds to a value very high, you may recieve the fatal error just after 1 second. Its better to use ‘
set_time_limit(0)‘ instead. Also, remember that when you are finished with the portion that performs the busy computation, its a good idea to call:
so that the remaining portion of the script finishes in 30 seconds or fatal error is thrown.