The default time allowed for a PHP script to execute is 30 seconds as mentioned in the php.ini file. The function used is set_time_limit(int sec). If the value passed is ‘0’, it takes unlimited time. It should be noted that if the default timer is set to 30 seconds and 20 seconds is specified in set_time_limit(), the script will run for 45 seconds.
This time can be increased by modifying max_execution_time in seconds. The time must be changed keeping in mind the environment of the server. This is because modifying the execution time will affect all the sites hosted by the server.
The script execution time can be increased by:
Using the sleep() function in the PHP script
Using the set_time_limit() function
The default limit is 30 seconds. The time limit can be set to zero to impose no time limit
To know more about PHP, enroll in our Online PHP Training Course now!