📅  最后修改于: 2023-12-03 15:03:38.920000             🧑  作者: Mango
PHP | IntlChar::chr()函数是一个用于Unicode字符的函数,它可以将一个Unicode码点转换为相应的字符。
IntlChar::chr ( int $codepoint ) : string
参数 | 描述 ---|--- codepoint | 需要转换的Unicode码点
返回对应于给定Unicode码点的字符的字符串。
<?php
echo IntlChar::chr(65) . "\n";
echo IntlChar::chr(0x2603) . "\n";
echo IntlChar::chr(0x1F602) . "\n";
?>
输出结果:
A
☃
😂
<?php
$codepoints = array(0x61, 0x62, 0x63, 0x1F601);
foreach ($codepoints as $cp) {
echo 'U+' . sprintf('%04X', $cp) . ': '
. IntlChar::chr($cp) . "\n";
}
?>
输出结果:
U+0061: a
U+0062: b
U+0063: c
U+1F601: 😁