set_time_limit()
set_time_limit() — Limits the maximum execution time.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.
Signature
set_time_limit(int $seconds): bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $seconds | int | The maximum execution time, in seconds. If set to zero, no time limit is imposed. |
Return value
Returns true on success, or false on failure.
Example
The PHP manual ships no example for set_time_limit(); the signature and the parameter table above are the contract.
All PHP 8.5 built-in functions
Reference card built from the PHP manual page set_time_limit() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.