PHP 7: Unicode escape syntax doesn't work on s

2019-09-24 01:27发布

Whenever strings are set with single quotes the unicode doesn't get decoded but the unicode does get decoded when set with double quotes.

How do I get the strings set by single quotes also to be decoded?

PHP

$poo = '\u{1F6BB}';
echo $poo;
$poo = "\u{1F6BB}";
echo $poo;

OUTPUT

\u{1F6BB}

1条回答
时光不老,我们不散
2楼-- · 2019-09-24 02:00

The point of single-quoted strings is that they don't support escape characters.

The documentation says this very clearly:

All other instances of backslash will be treated as a literal backslash: this means that the other escape sequences you might be used to, such as \r or \n, will be output literally as specified rather than having any special meaning.

查看更多
登录 后发表回答