Home >php教程 >php手册 >php 缓冲技术中常用几个实例

php 缓冲技术中常用几个实例

WBOY
WBOYOriginal
2016-06-13 10:00:251018browse

 

//初始化session
session_start();
//添加url rewrite的值
output_add_rewrite_var('var','value');
//插入一个连接
echo 'link';
//发送缓冲区数据
ob_flush();
//重置url rewrite的值
output_reset_rewrite_vars();
//插入一个连接
echo 'link';

/*

*/

print_r(ob_list_handlers());     //列出使用的输出句柄,将输出default output handler
ob_end_flush();        //发送缓冲区数据并关闭缓冲区
ob_start("ob_gzhandler");      //打开缓冲区,并使用ob_gzhandler
print_r(ob_list_handlers());     //列出输出句柄,将输出ob_gzhandler
ob_end_flush();        //发送缓冲区数据并关闭缓冲区
ob_start(create_function('$string','return $string;')); //打开缓冲区
print_r(ob_list_handlers());     //列出使用的输出句柄,将输出default output handler
ob_end_flush();        //发送缓冲区数据并关闭缓冲区

/*

*/

if(ob_get_level()==0)      //判断缓冲区等级,如果没有活动缓冲区
ob_start();        //打开缓冲区
for($i=0;$i {
  echo "
line to show.";    //输出内容
  echo str_pad('',4096)."n";    //输出生成的字符串
  ob_flush();       //发送缓冲区数据
  flush();        //刷新缓冲区
  sleep(1);       //暂停1秒
}
echo "done.";       //输出操作完成标记
ob_end_flush();       //发送缓冲区数据,并关闭缓冲区

?>

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