PHP output text before sleep

前端 未结 6 1947
走了就别回头了
走了就别回头了 2020-12-02 00:36

I want PHP to output some text, then sleep for a second and a half, and then output some more text.



        
6条回答
  •  时光说笑
    2020-12-02 01:05

    I think it is more a http request/response issue. On the command line your script works fine.

    Normally the response is prepared completely and send to the client. If your response has such a size that multiple tcp packages have to be send, it could happen that the first packages are send, before you script is ready with processing. So it depends on the size of the output. Depending on the client/web browser, it could also happen that the first packages get rendered, before the complete response arrives at the client.

    As Noufal Ibrahim answered while im typing, I totally agree with him. Do it in a asynchrone manner.

提交回复
热议问题