Description
$seconds
) : int
Delays the program execution for the given number of
seconds
.
Return Values
Returns zero on success, or FALSE
on error.
If the call was interrupted by a signal, sleep() returns
a non-zero value. On Windows, this value will always be
192 (the value of the
WAIT_IO_COMPLETION
constant within the Windows API).
On other platforms, the return value will be the number of seconds left to
sleep.
Errors/Exceptions
If the specified number of seconds
is negative,
this function will generate a E_WARNING
.
Changelog
Version | Description |
---|---|
5.3.4 |
Before PHP 5.3.4, on Windows, sleep() always
returns NULL when sleep has occurred, regardless of whether the
sleep was interrupted or not.
|
Examples
Example #1 sleep() example
<?php
// current time
echo date('h:i:s') . "\n";
// sleep for 10 seconds
sleep(10);
// wake up !
echo date('h:i:s') . "\n";
?>
This example will output (after 10 seconds)
05:31:23 05:31:33
See Also
- usleep() - Delay execution in microseconds
- time_nanosleep() - Delay for a number of seconds and nanoseconds
- time_sleep_until() - Make the script sleep until the specified time
- set_time_limit() - Limits the maximum execution time
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-sleep.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.