Can any body explain me what is the difference among sleep() and usleep() in PHP.
I have directed to use following scripts to do chat appli
The argument to sleep is seconds, the argument to usleep is microseconds. Other than that, I think they're identical.
sleep($n) == usleep($n * 1000000)
usleep(25000) only sleeps for 0.025 seconds.
sleep() allows your code to sleep in seconds.
sleep(5); // sleeps for 5 secondsusleep() allows your code with respect to microseconds.
usleep(2500000); // sleeps for 2.5 secondsOne other difference is sleep returns 0 on success, false on error. usleep doesn't return anything.
usleep() is used to delay execution in "microseconds" while sleep() is used to delay execution in seconds.
So usleep(25000) is 0.025 seconds.
Is there any difference between the two?
Simply
usleepusesCPU Cycleswhilesleepdoes not.
sleep takes seconds as argument
while usleep takes microseconds as argument