Php urlencode problems

Source: Internet
Author: User
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.

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.