Is there a way to have PHP print the data to a web browser in real time?

后端 未结 8 449
误落风尘
误落风尘 2020-12-17 21:00

For example, if I have an echo statement, there\'s no guarantee that the browser might display it right away, might display a few dozen echo statements at once, and might wa

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-17 21:40

    Enabling implicit flush as blueyed said should do the trick since it calls flush after every echo however some browsers also require no-cache headers to be set. Here is what I use. Your mileage may vary depending on the browser.

    header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    header('Pragma: no-cache');
    

提交回复
热议问题