PHP output text before sleep

前端 未结 6 1946
走了就别回头了
走了就别回头了 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 00:52

    Pentium10's answer did not quite work for me.. However when I went to the PHP documentation page, there were a lot of good comments on there.

    http://php.net/manual/en/function.ob-flush.php

    This worked for me using Firefox 3.5.9, PHP 5.2.11, Apache running off local Windows 7 laptop:

    echo "test";
    ob_end_flush();
    flush();
    usleep(x);
    echo "test";
    

    The ob_end_flush() was crucial to getting data sent.

提交回复
热议问题