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 ?
- p5.js | arc() Function
- PHP | each() Function
- p5.js | red() function
- p5.js | cos() function
- p5.js | sin() function
- D3.js | d3.set.has() Function
- PHP | min( ) Function
- p5.js | log() function
- p5.js | second() function
- D3.js | d3.mean() function
- PHP | ord() Function
- D3.js | d3.sum() 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 firstname.lastname@example.org. 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.