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

前端 未结 13 2522
时光说笑
时光说笑 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:11

    I wouldn't typically use it for serving web pages, but it's useful for command line scripts.

    $ready = false;
    do {
      $ready = some_monitor_function();
      sleep(2);
    } while (!$ready);
    

提交回复
热议问题