日期:2011-08-08  浏览次数:20481 次

1. 运行时配置(php.ini) 
    output_buffering = Off 
    display_errors = On 

2. 函数说明 
(1)bool ob_start ([ callback $output_callback [, int $chunk_size [, bool $erase ]]] ) 
    此函数将打开输出缓冲。当输出缓冲是活跃的时候,没有输出能从脚本送出(除http标头外),相反输出的内容被存储在内部缓冲区中。内部缓冲区的内容可以用 ob_get_contents() 函数复制到一个字符串变量中。想要输出存储在内部缓冲区中的内容,可以使用 ob_end_flush() 函数。另外,使用ob_end_clean() 函数会静默丢弃掉缓冲区的内容。 


01 <?php
02 function callback($buffer) {
03   // replace all the apples with oranges
04   return (str_replace("apples", "oranges", $buffer));
05 }
06 ob_start("callback");
07 ?>
08 <html>
09 <body>
10 <p>It's like comparing apples to oranges.</p>
11 </body>
12 </html>
13 <?php
14 ob_end_flush();
15 ?>
16  
17 输出:
18 <html>
19 <body>
20 <p>It's like comparing oranges to oranges.</p>
21 </body>
22 </html>

(2)string ob_get_contents ( void ) 
    只是得到输出缓冲区的内容,但不清除它,或者如果输出缓冲区无效将返回FALSE 。 


友情链接: 爱易网 云虚拟主机技术 云服务器技术 程序设计技术 开发网站 APP开发教程
Copyright © 2013-2024 爱易网页 当前在线:1256人  网站在17时46分34秒内访问总人数:205161人 当前 58.48%  粤ICP备18100884号-2
01 <?php