PHP – 使用 mb_get_info() 获取 mbstring 的内部设置
phpserver side programmingprogramming更新于 2025/7/18 20:37:17
PHP 中的 mb_get_info() 函数用于获取 mbstring 的内部设置。此函数在 PHP 5.4 及更高版本中受支持。
语法
array|string|int mb_get_info(str $type = "all")
参数
它仅接受一个参数来获取多字节信息。
$type −如果未指定 type 参数或将其指定为 "all",则将返回以下信息 −
"internal_encoding"、"http_input"、"http_output"、"http_output_conv_mimetypes"、"mail_charset"、"mail_header_encoding"、"mail_body_encoding"、"illegal_chars"、"encoding_translation"、"language"、"detect_order"、"substitute_character"、"strict_detection"
如果 type 参数指定为以下任一类型 −
"internal_encoding"、"http_input"、"http_output"、"http_output_conv_mimetypes"、"mail_charset"、"mail_header_encoding"、"mail_body_encoding"、"illegal_chars"、"encoding_translation"、"language"、"detect_order"、"substitute_character"或"strict_detection",
则返回指定的设置参数。
返回值
mb_get_info() 如果未指定类型,则返回一个包含类型信息的数组;否则,返回一个指定的类型。失败时返回 false。
注意 &minus:从 PHP 8.0.0 开始,"func_overload" 和 "func_overload_list" 类型不再受支持。
示例
<?php $string=mb_get_info(); print_r($string); ?>
输出
Array
(
[internal_encoding] => UTF-8
[http_output] => UTF-8
[http_output_conv_mimetypes] => ^(text/|application/xhtml\+xml)
[mail_charset] => UTF-8
[mail_header_encoding] => BASE64
[mail_body_encoding] => BASE64
[illegal_chars] => 0
[encoding_translation] => Off
[language] => neutral
[detect_order] => Array
(
[0] => ASCII
[1] => UTF-8
)
[substitute_character] => 63
[strict_detection] => Off
)

