From a review of the PHP documentation on usleep
and that of sleep
, you'll notice that there are 2 differences:
The argument for usleep
is an integer representing micro seconds (a micro second is one millionth of a second), while the argument for sleep
is an integer representing seconds.
sleep
returns "zero on success, or FALSE on error." usleep
has no return value. Here are more details on the return value for sleep
:
If the call was interrupted by a signal, sleep() returns a non-zero
value. On Windows, this value will always be 192 (the value of the
WAIT_IO_COMPLETION constant within the Windows API). On other
platforms, the return value will be the number of seconds left to
sleep.
In general, you should be ok using these functions within loops. That being said, though, the more important questions to ask are: Why do you need a solution that depends on halting execution for a certain amount of time? Is this really a good solution to your problem, or is it a hack-fix for some strange bug or edge case that you just want to have go away?