The time_nanosleep() function in PHP is an inbuilt function which is used to delay the execution of the current script for a specified number of seconds and nanoseconds.
The time_nanosleep() function accepts seconds and nanoseconds as parameters and returns TRUE on success or FALSE on failure.
If the delay is interrupted by a signal, an associative array is returned with the following components:
- seconds: It denotes the number of seconds remaining in the delay.
- nanoseconds: It denotes the number of nanoseconds remaining in the delay.
The time_nanosleep() function in PHP accepts two parameters.
- seconds : It is a mandatory parameter which specifies the number of seconds.
- nanoseconds : It is a mandatory parameter which specifies the number of nanoseconds.
Return Value: It returns TRUE on success or FALSE on failure.If the delay is interrupted by a signal, an associative array is returned with the remaining seconds and nanoseconds.
Errors And Exceptions:
- The value of nanoseconds passed as parameter must be less than 1, 000, 000, 000.
- The value of seconds passed as parameter should be non-negative.
Below programs illustrate the time_nanosleep() function:
Execution delayed for two and half a second
- How to get the function name inside a function in PHP ?
- CSS | rgb() Function
- PHP | Ds\Set last() Function
- PHP | Ds\Set first() Function
- PHP | Ds\Set add() Function
- PHP Ds\Set sum() Function
- PHP | Ds\Map xor() Function
- PHP | end() Function
- CSS | var() Function
- D3.js | d3.mean() function
- PHP | tan( ) Function
- CSS | hsl() Function
- p5.js | sq() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.