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