Difference between URL encoding in php and rawurlencode in Space Encoding

Source: Internet
Author: User
I recently used urlencode to encode the string and found that it encodes the space string to +. However, if you use rawurlencode to encode the string, the space string will change to % 20. After a space is entered in the browser, it will convert it to % 20. What is the difference between the two? Backend server...

I recently usedurlencodeWhen encoding a string, it is found that it encodes the space string+But if you userawurlencodeTo encode the space string.%20. After entering a space in the browser, it will convert it%20.

What is the difference between the two? What are the differences between backend servers when they accept these two encoding requests?

I triedhttp://zh.wikipedia.org/wiki/Internet%20Explorer%207Replace the URLhttp://zh.wikipedia.org/wiki/Internet+Explorer+7And cannot be identified.

Reply content:

I recently usedurlencodeWhen encoding a string, it is found that it encodes the space string+But if you userawurlencodeTo encode the space string.%20. After entering a space in the browser, it will convert it%20.

What is the difference between the two? What are the differences between backend servers when they accept these two encoding requests?

I triedhttp://zh.wikipedia.org/wiki/Internet%20Explorer%207Replace the URLhttp://zh.wikipedia.org/wiki/Internet+Explorer+7And cannot be identified.

From Wikipedia (emphasis and link added ):

When data that has been entered into HTML forms is submitted, the form field names and values are encoded and sent to the server in an HTTP request message using method GET or POST, or, historically, via email. The encoding used by default is 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 way is 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.