Php url codec description

Source: Internet
Author: User
Tags alphanumeric characters

, Urldecode () and rawurldecode () decoded strings are encoded in UTF-8 format, if the URL contains Chinese, and the page setting is not a UTF-8, the decoded string must be converted before it can be properly displayed.

Php tutorial description of Chinese url Codec
In php, urlencode and rawurlencode are encoded in Chinese.
String urlencode (string str)
Returns a string. All non-alphanumeric characters except-_. In this string will be replaced with a semicolon (%) followed by two hexadecimal numbers. This encoding is described in rfc 1738 to protect the original characters from being interpreted as special url delimiters and protect the url format to prevent them from being transmitted to media (like some email systems) chaos During character conversion

*/

$ A = '? A = Chinese ';
$ Urlencode = urlencode ($ );
Echo $ urlencode; // % 3fa % 3d % d6 % d0 % ce % c4


/*
String rawurldecode (string str)
Returns a string of hundreds of semicolons (%) followed by two hexadecimal numbers. All strings are replaced with original characters.
*/

$ C = rawurlencode ($ urlencode); // a % 253d % 25d6% 25d0% 25ce % 25c4;
Echo $ c;


/*

Note that urldecode () and rawurldecode () are decoded in UTF-8 format. If the url contains Chinese characters and the page setting is not UTF-8, the decoded string must be converted before it can be properly displayed.

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.