The difference between PHP's UrlEncode and Rawurlencode for space coding

Source: Internet
Author: User
Tags urlencode

I recently found that urlencode when I encode a string, it encodes the space string in order + , but if you rawurlencode encode it, the space string becomes %20 . And when you enter a space in the browser, it will convert it to %20 .

What is the difference between the two? Will the backend server be different when accepting both of these encoding requests?

I tried to http://zh.wikipedia.org/wiki/Internet%20Explorer%207 replace the URL with a discovery that was http://zh.wikipedia.org/wiki/Internet+Explorer+7 not recognized.

Reply content:

I recently found that urlencode when I encode a string, it encodes the space string in order + , but if you rawurlencode encode it, the space string becomes %20 . And when you enter a space in the browser, it will convert it to %20 .

What is the difference between the two? Will the backend server be different when accepting both of these encoding requests?

I tried to http://zh.wikipedia.org/wiki/Internet%20Explorer%207 replace the URL with a discovery that was http://zh.wikipedia.org/wiki/Internet+Explorer+7 not recognized.

From Wikipedia (emphasis and link added):

When
data was been entered into HTML forms was submitted, the form field names and values are encoded and sent T o the server in an HTTP request message using method GET or POST, or, historically, via email. the encoding used by default are based on a very early version of the general URI percent-encoding rules, with a number of modifications such as newline normalization and replacing spaces with "+" instead of "%20". The MIME type of data encoded this to application/x-www-form-urlencoded, and it is currently defined (still in a very Outdated manner) in the HTML and XForms specifications.

Source:
HTTP://STACKOVERFLOW.COM/QUESTIONS/16 ...

Other references:
HTTP://STACKOVERFLOW.COM/QUESTIONS/12 ...

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