PHP缓存区使用详解
来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 20:57 点击:次
<?php
for ($i=0; $i<10; $i ) {
ob_start();
echo "This is iteration $i: ";
// * Dont do this!
// $buf = ob_get_contents();
// ob_clean();
// * Use this instead:
$buf = ob_get_flush();
//<SPAN style="COLOR: #ff0000">缓冲区关闭,竟然还有内容</SPAN>
$test=ob_get_contents();
echo $test,---->;
echo $buf;
echo memory_get_usage()." ";
echo <br />;
}
?>
<?php
for ($i=0; $i<10; $i ) {
ob_start();
echo "This is iteration $i: ";
// * Dont do this!
// $buf = ob_get_contents();
// ob_clean();
// * Use this instead:
$buf = ob_get_flush();
//缓冲区关闭,竟然还有内容
$test=ob_get_contents();
echo $test,---->;
echo $buf;
echo memory_get_usage()."";
echo <br />;
}
?>
ob_get_flush相当于ob_end_flush,只有一点区别,ob_get_flush获取缓存区内容,保存到变量中,并关闭缓存区。
for ($i=0; $i<10; $i ) {
ob_start();
echo "This is iteration $i: ";
// * Dont do this!
// $buf = ob_get_contents();
// ob_clean();
// * Use this instead:
$buf = ob_get_flush();
//<SPAN style="COLOR: #ff0000">缓冲区关闭,竟然还有内容</SPAN>
$test=ob_get_contents();
echo $test,---->;
echo $buf;
echo memory_get_usage()." ";
echo <br />;
}
?>
<?php
for ($i=0; $i<10; $i ) {
ob_start();
echo "This is iteration $i: ";
// * Dont do this!
// $buf = ob_get_contents();
// ob_clean();
// * Use this instead:
$buf = ob_get_flush();
//缓冲区关闭,竟然还有内容
$test=ob_get_contents();
echo $test,---->;
echo $buf;
echo memory_get_usage()."";
echo <br />;
}
?>
ob_get_flush相当于ob_end_flush,只有一点区别,ob_get_flush获取缓存区内容,保存到变量中,并关闭缓存区。
相关新闻>>
- 发表评论
-
- 最新评论 更多>>