time_nanosleep()
Like sleep() and usleep(), this function will pause the script’s execution. The difference is that time_nanosleep() works in nanoseconds. One billion nanoseconds equals one second.
The limit here is that the largest number allowed is one billion, which is one second. So, in order to sleep longer than one second using nanoseconds, this function has two parameters. The first is the delay in whole seconds; the second is the remainder of the delay in nanoseconds.
The values given must be a non-negative whole number. A negative number will generate a warning. And the second parameter must be less than one billion.
// Before echo date('H:i:s'); // Sleep 5.0000002 seconds time_nanosleep(5, 2000); // After echo "\n" . date('H:i:s'); /* 22:15:55 22:16:00 */
Returns true or false on success or failure. But if the delay was interrupted by a signal, an associative array is returned with the keys of “seconds” and “nanoseconds”. Each of those holding the corresponding amount of time left in the delay.
As of PHP 5.3 this function is available on Windows as well.
