A brief analysis of the Rawurlencode () and UrlEncode () function Differences _php Tutorial

Source: Internet
Author: User
This article to introduce to you about Rawurlencode () and UrlEncode () function Difference usage Introduction, dear friends can refer to.

Today when reading open source code found a URL of the encoding function: Rawurlencode (), has not been noticed, because in peacetime development is mainly used UrlEncode (), so specialized research.

In fact, the difference between the two functions is very simple, they are two will be the URL of the non-English characters escaped, replaced by "%" followed by two hexadecimal digits, the difference is: Rawurlencode compliance is the 94 international standard Memo RFC 1738, the escape of the space is '%20′ While UrlEncode's code implements the traditional approach, the same as the post form data, the space is escaped to the "+" sign.

As an example:
If the URL address source is in the form of: http://www.bKjia.c0m encoding Difference
Rawurlencode ($url):
Http%3a%2f%2fityizhan.com%2fphp%20%e7%bc%96%e7%a0%81%e5%8c%ba%e5%88%ab%2b
UrlEncode ($url):
Http%3a%2f%2fityizhan.com%2fphp+%e7%bc%96%e7%a0%81%e5%8c%ba%e5%88%ab%2b

The difference between the two can be clearly seen from this example, and if we want to decode the encoded URL, we can use both functions: Rawurldecode (), UrlDecode (). In the actual development in order to avoid the URL format is not uniform, it is recommended that you use Rawurlencode () to the URL encoding.

The same operation in JavaScript also has some differences, you can refer to: JavaScript URL encoding and anti-coding, which tells the JavaScript in the Escape (), encodeURI (), encodeURIComponent () The encoding uses

http://www.bkjia.com/PHPjc/629826.html www.bkjia.com true http://www.bkjia.com/PHPjc/629826.html techarticle this article to introduce to you about Rawurlencode () and UrlEncode () function Difference usage Introduction, dear friends can refer to. Today, when I read the open source code, I found a URL encoding function: Ra ...

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