How does PHP use GET to transfer the encoding of Chinese characters? 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. the following code: $ strrawurlencode (iconv (GBK, UTF-8, who I am); echo & lt; br & gt ;. $ str ;? In this way, "my PHP uses GET to transfer the encoding and conversion of Chinese characters
? 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. the following code:
$ Str = rawurlencode (iconv ("GBK", "UTF-8", "who I am"); echo"
". $ 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;
?