PHP实现即时输出、实时输出内容方法_PHP教程

WBOY
Release: 2016-07-13 09:52:31
Original
1676 people have browsed it

PHP实现即时输出、实时输出内容方法

   这篇文章主要介绍了PHP实现即时输出、实时输出内容方法,本文直接给出实现方法,需要的朋友可以参考下

  老生长谈了。。纯备忘

  对于运行时间较长的PHP程序来说可能都需要即时输出内容来查看运行情况。

  代码如下:

  header(“Content-type:text/html;charset=utf-8″);

  #设置执行时间不限时

  set_time_limit(0);

  #清除并关闭缓冲,输出到浏览器之前使用这个函数。

  ob_end_clean();

  #控制隐式缓冲泻出,默认off,打开时,对每个 print/echo 或者输出命令的结果都发送到浏览器。

  ob_implicit_flush(1);

  例,

   代码如下:

  ob_end_clean();

  ob_implicit_flush(1);

  while(1){

  //部分浏览器需要内容达到一定长度了才输出

  echo str_repeat("

 

", 200).'hello sjolzy.cn
';

 

  sleep(1);

  //ob_end_flush();

  //ob_flush();

  //flush();

  }

  按例子测试,达到了PHP即时实时输出内容的效果。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1007651.htmlTechArticlePHP实现即时输出、实时输出内容方法 这篇文章主要介绍了PHP实现即时输出、实时输出内容方法,本文直接给出实现方法,需要的朋友可以参考...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!