Php urlencode: PHPcode & lt ;? Php $ name $ _ GET [name]; echourlencode ($ name );? & Gt; access XXX. php? The results returned by different browsers for different name data structures are different! Output in firefox7 and IE9 is % CA % FD % BE % DD % BD % E1 % B9 % B9, but the urlencode problem in chro php
The following test page is available:
PHP code
Access XXX. php? Name = data structure
Different browsers return different results!
Output in firefox7 and IE9 is % CA % FD % BE % DD % BD % E1 % B9 % B9, in chrome, the output is % E6 % 95% B0 % E6 % 8D % AE % E7 % BB % 93% E6 % 9E % 84 !!
In php, why is the result of urlencode processing related to the browser?
Another problem is that I want to make a simple form. the method is get.
But when the text is Chinese, it will be automatically encoded, assuming it is a "data structure ", the encoded result is % E6 % 95% B0 % E6 % 8D % AE % E7 % BB % 93% E6 % 9E % 84. This result is the same as the javascript encodeURIComponent processing result.
In php, I need to get % CA % FD % BE % DD % BD % E1 % B9 % B9 (that is, php urlencode ).
How can this problem be solved? In this case, if the result is obtained from encodeURIComponent, how can it be processed as the urlencode result.
------ Solution --------------------
Well, % E6 % 95% B0 % E6 % 8D % AE % E7 % BB % 93% E6 % 9E % 84
This is the result of urlencode after garbled characters. Convert the encoding format.
------ Solution --------------------
Discussion
Because you pass the value through the url, and the browser has an option "always sent in UTF-8 encoding"
% E6 % 95% B0 % E6 % 8D % AE % E7 % BB % 93% E6 % 9E % 84 is the url encoding of the UTF-8 data structure.
While
% CA % FD % BE % DD % BD % E1 % B9 % B9 is the url encoding of the gbk data structure.