How does php convert xE6x88x91 to a Chinese character? soon after learning php, today's whimsy want to convert a Chinese character into a hexadecimal form and then convert it into a Chinese character, so I wrote the following code:
Why can I directly write "\ xE6 \ x88 \ x91" if echo "$ s2" is not automatically converted into the word "?
If I get a string '\ xE6 \ x88 \ x91', how can I convert it to Chinese?
Reply to discussion (solution)
echo hex2bin(str_replace('\\x', '', '\xE6\x88\x91'));
Me
Apparently \ x is a snake foot
echo hex2bin(str_replace('\\x', '', '\xE6\x88\x91'));
Me
Apparently \ x is a snake foot
Thank you very much. if this happens in the future, you only need to remove \ x and then use the hex2bin function.
The main reason is that the characters written in double quotation marks in the manual can be written in the form of \ x [0-9A-Fa-f] {}.
$ S = '\ xE6 \ x88 \ x91 ';
Then echo "$ s" is written in this way, and it will be automatically converted. it does not seem to work.
Thanks again!
$ S = '\ xE6 \ x88 \ x91 ';
$ F = create_function (''," return \ "$ s \";");
Echo $ f ();
Eval ("echo \" $ s \";");