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

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

    I had to use it recently when I was utilising Google's Geolocation API. Every address in a loop needed to call Google's server so it needed a bit of time to receive a response. I used usleep(500000) to give everything involved enough time.

提交回复
热议问题