Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

string - PHP 7: Unicode escape syntax doesn't work on single quotes

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}??

Example

http://sandbox.onlinephpfunctions.com/code/9a38e972226a6271996f512363c19332dae0b760

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 or , will be output literally as specified rather than having any special meaning.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...