Is sleep time included in the execution time limit?
P粉766520991
P粉766520991 2023-08-24 11:23:11
0
2
700
<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>
P粉766520991
P粉766520991

reply all(2)
P粉921130067

In the PHP sleep() page, there are the following user-contributed comments:

P粉674876385

You should try this whenever you have a script that sleeps longer than the maximum execution time.

<?php
  sleep(ini_get('max_execution_time') + 10);
?>

Spoiler: Under Linux, sleep time is ignored, but under Windows, it counts as execution time.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template