PHP遍历循环时回显结果 [英] php echo the result while iterating through the loop

查看:146
本文介绍了PHP遍历循环时回显结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是执行循环,内部循环中有数据处理功能.

I am execution loop and inside loop there is data processing function inside loop.

  for($i = 0 ; $i <=680 ; $i = $i + 40)
    {
          $url = 'http://www.yelp.com/biz/franchino-san-francisco?start=80';
          $root = yelp($url);
          var_dump($root);
    }

此循环执行需要很长时间,并且在整个循环结束时将在最后回显结果.

This loop takes long time to execute, and results are echoed at the end when entire loop completes.

如何在每次迭代期间回显结果?

How can I echo the result during each iteration?

实际上这里会发生什么?结果是否存储在缓冲区中,并在末尾回显或显示什么?

Actually what happens here? does to result are stored in buffer and at the end echoed or what?

推荐答案

PHP缓冲输出.

如果要立即将内容输出到浏览器,可以使用flush()ob_flush()函数:

If you want to output stuff to the browser immediately you can use the flush() and ob_flush() functions:

for ($i = 0; $i <= 680; $i += 40) {
    $url = 'http://www.yelp.com/biz/franchino-san-francisco?start=80';
    $root = yelp($url);
    var_dump($root);
    flush();
    ob_flush();
}

这篇关于PHP遍历循环时回显结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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