PHP 8.3.4 Released!

mb_output_handler

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_output_handler在输出缓冲中转换字符编码的回调函数

说明

mb_output_handler(string $string, int $status): string

mb_output_handler() 是一个 ob_start() 回调函数。 mb_output_handler() 将输出缓冲中的字符从内部字符编码转换为 HTTP 输出的字符编码。

参数

string

输出缓冲的内容。

status

输出缓冲的状态。

返回值

转换后的 string

示例

示例 #1 mb_output_handler() 示例

<?php
mb_http_output
("UTF-8");
ob_start("mb_output_handler");
?>

注释

注意:

如果你想要输出二进制数据,比如图片,必须在任何二进制数据发送到客户端之前使用 header() 来设置 Content-Type: 头。(例如 header("Content-Type: image/png"))。 如果 Content-Type: 头已发送,输出字符编码的转换将不会执行。

注意,如果发送了 'Content-Type: text/*',则内容被认为是文本,将发生转换。

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top