ob_start([string output_callback])- 打开输出缓冲区
所有的输出信息不在直接发送到浏览器,而是保存在输出缓冲区里面,可选得回调函数用于处理输出结果信息.
ob_end_flush - 结束(发送)输出缓冲区的内容,关闭输出缓冲区,实例代码如下:
- */
-
- ob_start();
- echo "hello world";
- $out=ob_get_clean();
- $out=strtolower($out);
- var_dump($out);
-
-
- if(!function_exists('ob_clean'))
- {
- function ob_clean()
- {
- if(@ob_end_clean())
- {
- return ob_start();
- }
- trigger_error("ob_clean() failed to delete buffer.no buffer to delete.",e_user_notice);
- return false;
- }
- }
-
-
- header('content-type: multipart/x-mixed-replace;boundary=endofsection');
- print "n--endofsectionn";
- $pmt=array("-","","|","/");
- for($i=0;$i<10;$i++)
- {
- sleep(1);
- print "content-type: text/plainnn";
- print "part $it".$pmt[$i % 4];
- print "--endofsectionn";
- ob_flush();
- flush();
- }
- print "content-type: text/plainnn";
- print "the endn";
- print "--endofsection--n";
|