PHP usleep() Function
The PHP usleep() function is used to delay the program execution for the specified number of microseconds.
Syntax
usleep(microseconds)
Parameters
microseconds |
Required. Specify the halt time in microseconds. |
Note: Values larger than 1000000 (i.e. sleeping for more than a second) may not be supported by the operating system. In such case, sleep() function can be used.
Return Value
No value is returned.
Example: usleep() example
The example below shows the usage of usleep() function.
<?php //displaying the current time echo date('h:i:s')."\n"; //usleep for 2 seconds usleep(2000000); //wake up and displaying the current time echo date('h:i:s')."\n"; ?>
The output of the above code will be similar to:
04:37:41 04:37:43
❮ PHP Miscellaneous Reference