PHP time_nanosleep()Function

PHP Misc 参考手册PHP Misc Reference Manual

Examples

Delay execution of the current script for 3.5 seconds:

<?php
if (time_nanosleep(3,500000000) === true)
{
echo "Slept for three and a half a second";
}
?>

Run Example »

Definition and Usage

The time_nanosleep() function delays execution of the current script for a number of seconds and nanoseconds.


Syntax

time_nanosleep(seconds,nanoseconds)

Parameters Description
seconds Required. Specifies the number of seconds to delay the script execution.
nanoseconds Required. Specifies the number of nanoseconds to delay the script execution (must be less than 1,000,000,000).

Technical Details

Return Value: Returns 0 on success, or FALSE on failure.

If the call was interrupted by a signal, an associative array with the number of seconds and nanoseconds remaining in the delay is returned.
PHP Version: 5+
Changelog: This function was not implemented on Windows platforms until PHP 5.3.0.


PHP Misc 参考手册PHP Misc Reference Manual Other Extensions