Show results while script is still executing

前端 未结 4 882
遇见更好的自我
遇见更好的自我 2020-11-28 06:16

Right now in order to see the results, I have to wait until the entire code is done executing. It hangs until it\'s complete and stays loading. Once it\'s finished it shows

4条回答
  •  孤独总比滥情好
    2020-11-28 06:42

    You can do that with output buffering. Turn on output buffering at the top of your script with ob_start(). That makes PHP to send no output to the browser. Instead its stored internally. Flush your output at any time with ob_flush(), and the content will be sent to the browser.
    But keep in mind that output buffering is influenced by many other factors. I think some versions of IIS will wait until the script is finished, ignoring output buffering. And some Antivirus software on client side (Was it Panda?) might wait until the page is fully loaded before passing it through to the browser.

提交回复
热议问题