mb_substitute_character
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
mb_substitute_character — 设置/获取替代字符
说明
当输入字符的编码是无效的,或者字符代码不存在于输出的字符编码中时,可以为其指定一个替代字符。
无效字符可以被替换为 null
(不输出)、string 或者 integer 值(Unicode 字符代码的值)。
该设置会影响 mb_convert_encoding()、 mb_convert_variables()、 mb_output_handler() 和 mb_send_mail()。
参数
-
substchar
-
指定 Unicode 值为一个 integer,或者是以下字符串中的一个:
-
"none"
::不输出 -
"long"
:输出字符代码的值(比如:U+3000
、JIS+7E7E
) -
"entity"
:输出字符的实体(比如:Ȁ
)
-
返回值
如果设置了 substchar
,在成功时返回 true
,失败时返回 false
。
如果没有设置 substchar
,它将返回当前设置。
范例
示例 #1 mb_substitute_character() 例子
<?php
/* 设置为 Unicode U+3013 (GETA MARK) */
mb_substitute_character(0x3013);
/* 设置十六进制格式 */
mb_substitute_character("long");
/* 显示当前设置 */
echo mb_substitute_character();
?>

User Contributed Notes
There are no user contributed notes for this page.
备份地址:http://www.lvesu.com/blog/php/function.mb-substitute-character.php