array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.mb-substitute-character.php', 1 => 'mb_substitute_character', ), 'up' => array ( 0 => 'ref.mbstring.php', 1 => '多字节字符串 函数', ), 'prev' => array ( 0 => 'function.mb-strwidth.php', 1 => 'mb_strwidth', ), 'next' => array ( 0 => 'function.mb-substr-count.php', 1 => 'mb_substr_count', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/mbstring/functions/mb-substitute-character.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
mb_substitute_character — 设置/获取替代字符
当输入字符的编码是无效的,或者字符代码不存在于输出的字符编码中时,可以为其指定一个替代字符。
无效字符可以被替换为 "none"
(不输出)、string 或者 int 值(Unicode 字符代码的值)。
该设置会影响 mb_convert_encoding()、 mb_convert_variables()、 mb_output_handler() 和 mb_send_mail()。
版本 | 说明 |
---|---|
8.0.0 |
不再支持将空字符串传递给 substitute_character ;应该传递 "none" 。
|
8.0.0 |
现在 encoding 可以为 null。
|
示例 #1 mb_substitute_character() 示例
<?php
/* 设置为 Unicode U+3013 (GETA MARK) */
mb_substitute_character(0x3013);
/* 设置十六进制格式 */
mb_substitute_character("long");
/* 显示当前设置 */
echo mb_substitute_character();
?>