Is there a way to make PHP progressively output as the script executes?

前端 未结 4 1746
孤城傲影
孤城傲影 2020-12-18 07:16

So I\'m writing a disposable script for my own personal single use and I want to be able see how the process is going. Basically I\'m processing a couple of thousand media r

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 07:41

    Use ob_flush to send any data in the buffer. So you can execute some commands, flush the output, and then sleep for a bit before processing more commands.

    I do notice that on particularly long scripts, PHP seems to start sending what it's got in the buffer even though the script hasn't finished executing

    By default, PHP will never echo anything until the entire script finishes executing. That's just your browser trying to output way too much data at once, or you have something that's causing it to flush somewhere.

提交回复
热议问题