PHP Chinese URL codec detailed description _php tutorial

Source: Internet
Author: User
Tags alphanumeric characters
, UrlDecode () and Rawurldecode () decoding the string is UTF-8 format encoding, if the URL contains Chinese words, and the page set is not UTF-8, then the decoded string to be converted to normal display

PHP Tutorial Chinese URL codec detailed description
In PHP, UrlEncode and Rawurlencode are encoded in Chinese.
String UrlEncode (String str)
Returns a string, in addition to-_, in this string. All non-alphanumeric characters are replaced with a percent (%) followed by a two-digit hexadecimal number. This is the encoding described in RFC 1738 to protect the literal characters from being interpreted as a special URL delimiter, while protecting the URL format from being confused by the transfer of media (like some messaging systems) using character conversions

*/

$a = '? a= Chinese ';
$urlencode =urlencode ($a);
Echo $urlencode; %3FA%3D%D6%D0%CE%C4


/*
String Rawurldecode (String str)
Returns a string that is replaced by a sequence of percent semicolons (%) followed by a two-digit hexadecimal number in this string.
*/

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


/*

One thing to note is that UrlDecode () and Rawurldecode () decode the string is utf-8 format encoding, if the URL contains Chinese words, and the page set is not Utf-8, then the decoded string to be converted to normal display

http://www.bkjia.com/PHPjc/632353.html www.bkjia.com true http://www.bkjia.com/PHPjc/632353.html techarticle , UrlDecode () and Rawurldecode () decode the string is encoded in UTF-8 format, if the URL contains Chinese words, and the page settings are not UTF-8, then to be decoded out of the string ...

  • 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.