Is sleep time included in the execution time limit?
P粉766520991
2023-08-24 11:23:11
<p>I have two questions about the <code>sleep()</code> function in PHP: </p>
<ol>
<li><p>Does sleep time affect the maximum execution time limit of PHP scripts? Sometimes, PHP displays the message "Maximum execution time exceeded 30 seconds". Will this message appear if I use <code>sleep(31)</code>? </p></li>
<li><p>Are there any risks in using the <code>sleep()</code> function? Will it consume a lot of CPU performance? </p></li>
</ol></p>
In the PHP sleep() page, there are the following user-contributed comments:
You should try this whenever you have a script that sleeps longer than the maximum execution time.
Spoiler: Under Linux, sleep time is ignored, but under Windows, it counts as execution time.