Home  >  Article  >  php教程  >  PHP使用缓存即时输出内容(output buffering)的方法

PHP使用缓存即时输出内容(output buffering)的方法

WBOY
WBOYOriginal
2016-06-06 19:48:471547browse

这篇文章主要介绍了PHP使用缓存即时输出内容(output buffering)的方法,实例分析了php缓存输出的相关使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下

PHP使用缓存即时输出内容(output buffering)的方法。分享给大家供大家参考。具体如下:

$buffer = ini_get('output_buffering'); echo str_repeat(' ',$buffer+1); //防止浏览器缓存 ob_end_flush(); //关闭缓存 for( $i=1; $i\n"; flush(); //刷新缓存(直接发送到浏览器) sleep(1); } echo '输出完毕!';

运行效果如下:

第 1 次输出.
第 2 次输出.
第 3 次输出.
第 4 次输出.
第 5 次输出.
第 6 次输出.
第 7 次输出.
第 8 次输出.
第 9 次输出.
第 10 次输出.
输出完毕!

希望本文所述对大家的php程序设计有所帮助。

Statement:
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