PHP Flush/ob_flush not working

前端 未结 7 2296
情深已故
情深已故 2020-11-27 07:03

I\'ve tried several attempts at getting my flush and ob_flush to work. I\'ve tried setting the ini to allow buffering, I\'ve tried using several different functions I found

7条回答
  •  长情又很酷
    2020-11-27 07:29

    This question seems to pop up a lot on a Google search, so I wanted to update it. It's September 2014.....

    @Netcoder 's answer does work, but Chrome will sometimes still output everything all at once.

    To fix this, simply added an ob_flush(), and flush() in the code, it will output after each second.

    Example:

    ob_implicit_flush(true);
    ob_end_flush();
    
    for ($i=0; $i<5; $i++) {
        echo $i.'
    '; ob_flush(); flush(); sleep(1); }

提交回复
热议问题