Encoding and decoding in PHP and JS

Source: Internet
Author: User

in PHP:

the urlencode method applies the URL encoding rule to the specified string. For example, a space is changed to a plus sign. In homepage, form data transmission uses urlencode encoding before being sent. All non-letter characters (except-, _,.) are replaced with two hexadecimal numbers after %, and spaces are replaced with the + number.

urldecode, decodes the code in the form of % # into a specified character, and the plus sign is decoded into a space.

original:

http://cn.php.net/urlencode

http://cn.php.net/manual/en/function.urldecode.php

http://baike.baidu.com/view/2996406.htm

in JS:

encodeuricomponent () the function can encode a string as a URI component. This method does not encode ASCII letters and numbers, and does not encode these ASCII punctuation marks :-_.! ~ *'().

other characters (such :;/?: @ & =+ $, # The punctuation marks used to separate URI components) are all replaced by one or more hexadecimal escape sequences.

note:

encodeuricomponent () function and encodeuri () function, the former assumes that its parameters are part of the URI (such as the Protocol, Host name, path, or query string ). Therefore, the encodeuricomponent () function uses escape characters to separate the punctuation marks of each part of the URI.

decodeuricomponent decodes the image.

Original article:

Http://www.w3school.com.cn/js/jsref_encodeURIComponent.asp

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.