Introduction: This is a detailed page for PHP to transfer Chinese characters using get. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 325735 'rolling = 'no'>
When we use get to transmit Chinese character encoding, different browsers may have different problems. Therefore, we should first transcode Chinese characters and convert them to Unicode for transmission, as shown below:Code:
$ STR = rawurlencode (iconv ("GBK", "UTF-8", "who I am"); echo "<br>". $ STR;
In this way, "Who am I" will be converted to a code similar to: % E6 % 88% E6 % 91% af % E8 % B0 % 81 and transmitted on the browser address;
When receiving this parameter, You need to reverse convert the encoding in two steps:
1. Define the encoding format of the page:
This is the first step. It requires the browser to display the encoding when reading this page. Therefore, we should add the header encoding definition on our page:
Header ("Content-Type: text/html; charset = GBK ");
What encoding is;
Ii. Received data:
When the get method is used for Chinese Character transmission, it will be parsed to unicode encoding by the browser. Therefore, we should first convert it to UTF-8 encoding:
$ _ Articlename = rawurldecode ($ _ articlename );
Rawurldecode is about to convert the encoding format similar to: % E6 % 88% E6 % 91% af % E8 % B0 % 81 to UTF-8;
Then use iconv to convert the encoding:
$ _ Articlename = iconv ("UTF-8", "GBK", "$ _ articlename ");
In this way, the GBK encoding is displayed normally;
Gb2312 is the same, just change GBK to gb2312;
More articles about "php uses get to transfer Chinese character encoding and conversion"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/325735.html pageno: 13.