How does php convert xE6x88x91 to Chinese?

Source: Internet
Author: User
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 \";");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.