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 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 '输出完毕!';
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.