UrlEncode Problems with PHP
The following test page is available
PHP Code
Accessing xxx.php?name= Data Structures
Different browsers return the results are actually different!
The output in firefox7 and IE9 is%ca%fd%be%dd%bd%e1%b9%b9, and the output under Chrome is%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84!!
Why is the UrlEncode function processed in PHP and the results are related to the browser?
Another problem is that I want to make a simple form, method for Get
But when the text is in Chinese, it will automatically encode, assuming that the "data structure", the result of the code is%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84. The result is the same as the encodeuricomponent processing of JavaScript.
And I need to get%ca%fd%be%dd%bd%e1%b9%b9 (that is, PHP's UrlEncode) in PHP-side processing.
How do you deal with such a thing, please? Or so, if it is the result obtained from encodeURIComponent, how to deal with UrlEncode result.
------Solution--------------------
Hmm,%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84.
This is the result of UrlEncode after garbled. Convert the encoding format.
------Solution--------------------
discuss
Because you are sending values through a URL, and the browser has an option "Always send with Utf-8 encoding"
%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84 is the URL encoding of the data structure UTF-8 encoding
and
%CA%FD%BE%DD%BD%E1%B9%B9 is the URL encoding of the data structure GBK encoding