问题描述
因此,我正在编写一次性脚本供个人个人使用,我希望能够看到该过程的进展情况.基本上,我正在处理数千个媒体版本,并将它们发送到我们的新CMS.
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 releases and sending them to our new CMS.
因此,我不会敲打CMS,每5个请求后,我就会将脚本sleep
制作几秒钟.
So I don't hammer the CMS, I'm making the script sleep
for a couple of seconds after every 5 requests.
我希望-在脚本执行时-能够看到我的echo
告诉我脚本正在休眠或与Web服务的最后一次交易成功.
I would like - as the script is executing - to be able to see my echo
s telling me the script is going to sleep or that the last transaction with the webservice was successful.
这在PHP中可行吗?
感谢您的帮助!
伊恩
推荐答案
使用ob_flush
发送缓冲区中的任何数据.因此,您可以执行一些命令,刷新输出,然后在处理更多命令之前先休眠一会儿.
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.
默认情况下,在整个脚本执行完毕之前,PHP永远不会回显任何内容.那只是您的浏览器试图一次输出太多数据,或者您的某些东西导致其刷新到某处.
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.
这篇关于有没有办法使脚本执行时逐步输出PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!