Current Location: Home> Function Categories> time_nanosleep

time_nanosleep

Delay execution for several seconds and nanoseconds
Name:time_nanosleep
Category:Miscellaneous
Programming Language:php
One-line Description:Delay the code execution by the specified number of seconds and nanoseconds.

Definition and usage

time_nanosleep() function delays the execution of the current script by the specified number of seconds and nanoseconds.

Note: On Windows, the system's sleep time may exceed the specified number of nanoseconds, depending on the hardware.

Example

Delay the execution of the current script by 3.5 seconds:

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

Try it yourself

grammar

 time_nanosleep ( seconds , nanoseconds )
parameter describe
seconds Required. Specifies the number of seconds to delay the script.
nanoseconds Required. Specifies the number of nanoseconds to delay the script (must be less than 1,000,000,000).

illustrate

Delays the program execution of the specified number of seconds and nanoseconds .

Return value

Return TRUE if successful, and FALSE if failed

If the delay is interrupted by a signal, an associative array with the following components is returned:

  • seconds - the number of seconds remaining in the delay
  • nanoseconds - the number of nanoseconds remaining in the delay