Modifying PHP's Maximum Execution Time
Question:
Is it possible to extend PHP's maximum execution time from within a PHP script itself, without modifying the php.ini file?
Answer:
Yes, it is possible to increase the maximum execution time from your PHP file using ini_set(). This function allows you to set or change the value of a PHP configuration setting at runtime.
Here's how to do it:
ini_set('max_execution_time', '300'); // for 5 minutes
This code will set the maximum execution time to 300 seconds. To set it to an infinite amount of time, use '0' as the value:
ini_set('max_execution_time', '0'); // for infinite time
Place this code at the beginning of your PHP script, and it will take effect for the entire script.
By utilizing ini_set(), you can alter the maximum execution time dynamically within your PHP code, without having to make any modifications to the php.ini file.
The above is the detailed content of Can I Increase PHP's Max Execution Time from Within a Script?. For more information, please follow other related articles on the PHP Chinese website!