Delay execution of the current script for 5 seconds:
<?phpecho date('h:i:s') . "<br>";//sleep for 5 secondssleep(5);//start againecho date('h:i:s');?>The sleep() function delays execution of the current script for a few seconds.
Note: If the specified number of seconds is negative, this function will throw an error.
sleep( seconds )
parameter | describe |
---|---|
seconds | Required. Specifies the number of seconds to delay script execution. |
Return value: | Returns 0 if successful or FALSE if error occurs. If the call is interrupted by a signal, this function returns a non-zero value. On Windows platforms, this value will always be 192 , representing the value of the WAIT_IO_COMPLETION constant in the Windows API. On other platforms, the return value will be the remaining latency seconds. |
---|---|
PHP version: | 4+ |
Update log: | In versions prior to PHP 5.3.4, this function always returned NULL when called on Windows platforms. |