mb_output_handler()
(PHP 4 >= 4.0.6, PHP 5, PHP 7)
在输出缓冲中转换字符编码的回调函数
说明
mb_output_handler(string $contents,int $status): string
mb_output_handler()是一个ob_start()回调函数。mb_output_handler()将输出缓冲中的字符从内部字符编码转换为 HTTP 输出的字符编码。
参数
- $contents
输出缓冲的内容。
- $status
输出缓冲的状态。
返回值
转换后的string。
更新日志
版本 | 说明 |
---|---|
4.1.0 | 当遇到以下条件的时候,该函数将添加 HTTP 字符编码头:
|
范例
mb_output_handler()例子
<?php mb_http_output("UTF-8"); ob_start("mb_output_handler"); ?>
注释
Note:如果你想要输出二进制数据,比如图片,必须在任何二进制数据发送到客户端之前使用header()来设置 Content-Type:头。(例如 header("Content-Type: image/png"))。如果 Content-Type:头已发送,输出字符编码的转换将不会执行。
注意,如果发送了'Content-Type: text/*',则内容被认为是文本,将发生转换。
参见
ob_start()
打开输出控制缓冲