PHP sleep () function
Examples
5 seconds delay execution of the current script:
<?php
echo date('h:i:s') . "<br>";
//sleep for 5 seconds
sleep(5);
//start again
echo date('h:i:s');
?>
echo date('h:i:s') . "<br>";
//sleep for 5 seconds
sleep(5);
//start again
echo date('h:i:s');
?>
Running instance »
Definition and Usage
sleep () function delays execution of the current script for several seconds.
NOTE: If you specify the number of seconds is negative, this function will throw an error.
grammar
sleep( seconds )
参数 | 描述 |
---|---|
seconds | 必需。规定延迟执行脚本的秒数。 |
technical details
return value: | If successful, it returns 0 if an error is returned FALSE. If the call was interrupted by a signal, the function returns a nonzero value. On Windows platforms, this value will always be 192, it represents the value of the Windows API WAIT_IO_COMPLETION constants. On other platforms, the return value is the number of seconds remaining in the delay. |
---|---|
PHP version: | 4+ |
Update log: | In the previous version 5.3.4 PHP, when you call the function on the Windows platform, always returns NULL. |
PHP Misc Reference Manual