Function name: set_time_limit()
Applicable version: PHP 4, PHP 5, PHP 7
Function description: The set_time_limit() function is used to set the maximum execution time of the current script. When the script execution time exceeds the set time limit, PHP will interrupt the script execution.
Syntax: set_time_limit ( int $seconds ) : bool
parameter:
- seconds: Set the maximum execution time of the script, in seconds. If the parameter is 0, it means that the execution time of the script is not limited.
Return value:
- Return true if the setting is successful.
- If the setting fails or the function to set the maximum execution time is disabled, false is returned.
Example 1: Set the maximum execution time of the script to 10 seconds
set_time_limit(10);
Example 2: Disable script execution time limit
set_time_limit(0);
Notes:
- The set_time_limit() function only affects the execution time of the current script and will not affect the execution time of other scripts or external resources contained.
- If PHP is running in safe mode, the set_time_limit() function may be disabled and the maximum execution time of the script cannot be set.
- Carefulness is required when using the set_time_limit() function. Setting too long execution time may lead to too long script execution time and affect server performance.