Home > Backend Development > PHP Tutorial > PHP uses the method of caching instant output content (output buffering), outputbuffering_PHP tutorial

PHP uses the method of caching instant output content (output buffering), outputbuffering_PHP tutorial

WBOY
Release: 2016-07-13 09:45:06
Original
978 people have browsed it

PHP uses the method of caching the immediate output content (output buffering), outputbuffering

PHP uses the method of caching the immediate output content (output buffering). Share it with everyone for your reference. The details are as follows:

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

Copy after login

The operation effect is as follows:

1st output.
2nd output.
The 3rd output.
The 4th output.
The 5th output.
The 6th output.
The 7th output.
The 8th output.
9th output.
The 10th output.
Output completed!

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1042690.htmlTechArticlePHP uses the method of caching the immediate output content (output buffering), outputbuffering PHP uses the method of caching the immediate output content (output buffering) method. Share it with everyone for your reference. Specifically...
Related labels:
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