在脚本仍在执行时显示结果 [英] Show results while script is still executing

查看:132
本文介绍了在脚本仍在执行时显示结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在要查看结果,我必须等到整个代码执行完毕.它会挂起,直到完成并保持加载状态.完成后,它会显示我正在寻找的所有信息.在脚本仍在运行时,是否仍要显示此信息?所以说,如果我在代码的顶部有打印,我希望它显示在调用脚本时而不是在脚本执行完成时显示.

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 all the information I was looking for.. Is there anyway to show this while the script is still running? So say if I have a print somewhere at the top of my code, I want it to show when it's called not when the script is done executing.

有人知道该怎么做吗?

谢谢

推荐答案

您可以使用输出缓冲是这样的:

ob_start();

echo('doing something...');

// send to browser
ob_flush();

// ... do long running stuff
echo('still going...');

ob_flush();

echo('done.');
ob_end_flush(); 

这篇关于在脚本仍在执行时显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆