What is a practical use for PHP's sleep()?

前端 未结 13 2733
时光说笑
时光说笑 2020-12-23 19:17

I just had a look at the docs on sleep().

Where would you use this function?

Is it there to give the CPU a break in an expensive function?

Any common

13条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 20:05

    Another way to use it: if you want to execute a cronjob more often there every minute. I use the following code for this:

    sleep(30);
    include 'cronjob.php';
    

    I call this file, and cronjob.php every minute.

提交回复
热议问题