您的位置:首页 > 编程语言 > PHP开发

PHP输出缓冲控制函数及参数示例

2018-09-13 18:37 771 查看
简介

安装/配置

需求

安装

运行时配置

资源类型

预定义常量

范例

基本用法

Output Control 函数

flush — 刷新输出缓冲

ob_clean — 清空(擦掉)输出缓冲区

ob_end_clean — 清空(擦除)缓冲区并关闭输出缓冲

ob_end_flush — 冲刷出(送出)输出缓冲区内容并关闭缓冲

ob_flush — 冲刷出(送出)输出缓冲区中的内容

ob_get_clean — 得到当前缓冲区的内容并删除当前输出缓。

ob_get_contents — 返回输出缓冲区的内容

ob_get_flush — 刷出(送出)缓冲区内容,以字符串形式返回内容,并关闭输出缓冲区。

ob_get_length — 返回输出缓冲区内容的长度

ob_get_level — 返回输出缓冲机制的嵌套级别

ob_get_status — 得到所有输出缓冲区的状态

ob_gzhandler — 在ob_start中使用的用来压缩输出缓冲区中内容的回调函数。ob_start callback function to gzip output buffer

ob_implicit_flush — 打开/关闭绝对刷送

ob_list_handlers — 列出所有使用中的输出处理程序。

ob_start — 打开输出控制缓冲

output_add_rewr
b60
ite_var — 添加URL重写器的值(Add URL rewriter values)

output_reset_rewrite_vars — 重设URL重写器的值(Reset URL rewriter values)

The manual is a little shy on explaining that output buffers are nested, and that "turns off output buffering" means turning off the highest nested buffer. See ob_get_level (for a useful function, but still no explanation)

<?php
ob_start();
echo "1:blah\n";
ob_start();
echo "2:blah";
// ob_get_clean() returns the contents of the last buffer opened. The first "blah" and the output of var_dump are flushed from the top buffer on exit
&
2230
nbsp; var_dump(ob_get_clean());
exit;
?>

puts:
1:blah
string(6) "2:blah"

Prior to realising this, I had thought PHP's ob functionality left more to be desired. I *really* wish I knew earlier.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  PHP