PHP sleep()Functions
Examples
Delay the execution of the current script by 5 seconds:
echo date('h:i:s') . "<br>";
//Delay for 5 seconds
sleep(5);
//Output the time again
echo date('h:i:s');
Run Example »
Definition and Usage
The sleep() function delays the execution of the current script by a number of seconds.
Note:If the specified number of seconds is negative, the function will throw an error.
Syntax
sleep(seconds)
| Parameters | Description |
|---|---|
| seconds | Required. Specifies the number of seconds to delay the execution of the script. |
Technical Details
| Return Value: | Returns 0 on success, or FALSE on failure. If the call is interrupted by a signal, the function returns a non-zero value. On Windows platforms, this value will always be192, which represents the value of the WAIT_IO_COMPLETION constant in the Windows API. On other platforms, the return value will be the remaining number of seconds to delay. |
|---|---|
| PHP Version: | 4+ |
| Changelog: | In versions prior to PHP 5.3.4, this function always returned NULL when called on Windows platforms. |
PHP Misc Reference Manual Other Extensions