Difference between phpurlencode and rawurlencode

Source: Internet
Author: User
Tags alphanumeric characters
Urlencode is used to encode a string. replace all non-alphanumeric characters except "-_" in the original string with a semicolon (%) followed by two hexadecimal numbers, however, note that due to historical reasons, spaces are replaced with the + number. Rawurlencode is used to encode strings like urlencode. The only difference is that it uses RFC17

Urlencode is used to encode a string. replace all non-alphanumeric characters except "-_" in the original string with a semicolon (%) followed by two hexadecimal numbers, however, note that due to historical reasons, spaces are replaced with the + number. Rawurlencode is used to encode strings like urlencode. The only difference is that it uses RFC17

Urlencode is used to encode a string. replace all non-alphanumeric characters except "-_" in the original string with a semicolon (%) followed by two hexadecimal numbers, however, note that due to historical reasons, spaces are replaced with the + number. Rawurlencode is actually used to encode strings like urlencode. The only difference is that it uses RFC1738 encoding, that is, it will replace the space with % 20.

The corresponding decoding functions are urldecode and rawurldecode. Refer to the instructions on the official website. Any % ##, plus sign ('+') in the encoded string given by urldecode is decoded into a space character; the semicolon (%) in the rawurldecode decoding character string is followed by two hexadecimal values. There are two differences: first, urldecode decoding decodes any two characters after the percent sign (%). For example, % MN can also be decoded but fails; rawurldecode only decodes the last two hexadecimal (0-9A-F) characters after the percent sign (%). Second, urldecode decodes the plus sign as a space.

Based on the description of the decoding function, we can infer that urldecode can be used to decode urlencode or rawurlencode. However, if the original string contains spaces, the string decoded using rawurlencode is different from the original string.

Original article address: difference between php urlencode and rawurlencode. Thank you for sharing it with me.

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.