Unicode 代码点转义语法

Unicode codepoint escape syntax

我正在尝试使用 "Unicode codepoint escape syntax" 通过其 unicode 显示表情符号。

基本语法是:

echo "\u{1f606}"; - And it works fine

然而,当我从变量中插入 unicode 时:

$unicode = "1f606";
echo "\u{".$unicode."}";

我收到“无效的 UTF-8 代码点转义序列”错误。

您不能使用“\u{}”符号进行转换,请改用mb_chr()。

示例:

$unicode= 0x1f606;
echo mb_chr($unicode);