How to echo output in real time, (before script finishes)?

后端 未结 1 1714
野趣味
野趣味 2021-01-06 16:44

How do i output to the browser before the script finishes executing?

For example, the code below will output all 100 \"hi\" at once, how do I make it so it will outp

相关标签:
1条回答
  • 2021-01-06 17:31

    Call ob_implicit_flush() before your loop.

    Note that this is not a guarantee (web server buffers, proxy buffers and web browsers who refuse to rerender are your enemy). It MAY help to echo some linefeeds (\n) as I seem to remember that there are browsers who will not rerender until they received a complete line.

    This will not work at all if you use output buffering (e.g. for compression using gzip (if the gzip modul you use uses buffering which is not uncommon) or other reasons).

    0 讨论(0)
提交回复
热议问题