Latest web development tutorials

PHP usleep () function

PHP Misc Reference Manual PHP Misc Reference Manual

Examples

5 seconds delay execution of the current script (5,000,000 nanoseconds):

<?php
echo date('h:i:s') . "<br>";

//sleep for 5 seconds
usleep(5000000);

//start again
echo date('h:i:s');
?>

Running instance »

Definition and Usage

usleep () function delays execution of the current script several microseconds (a microsecond equals one millionth of a second).

NOTE: If you specify the number of seconds is negative, this function will throw an error.


grammar

usleep( microseconds )

参数 描述
microseconds 必需。规定延迟执行脚本的微秒数。

technical details

return value: No return value.
PHP version: 4+
Update log: Until PHP 5 version, this function was implemented in the Windows platform.


PHP Misc Reference Manual PHP Misc Reference Manual