Home  >  Article  >  Backend Development  >  一段PHP在地址栏的汉语传值出现乱码

一段PHP在地址栏的汉语传值出现乱码

WBOY
WBOYOriginal
2016-06-13 13:13:42716browse

一段PHP在地址栏的中文传值出现乱码
在IE下,中文传值,最后一个汉字变成了乱码,导致抓不出数据。

但是在火狐里面又可以。

传值页面,mysql,查询,接收值页面,均是UTF-8字库

这是咋回事呢?

------解决方案--------------------
把这个参数url_encode($name);一下
接下来时再url_decode($_GET['Tclass']);
------解决方案--------------------

PHP code
//a.php 
<a href="b.php?Tclass=<?php%20echo%20urlencode('test%E5%A4%A9%E8%8A%B1%E6%9D%BF');?>">aaaa</a>

//b.php
$T_class=$_GET['Tclass'];
 echo urldecode($T_class);  //test天花板
<br><font color="#e78608">------解决方案--------------------</font><br>echo "
  • ";
    ------解决方案--------------------
    1.引号内包含的表达式不会被解析。
    PHP code
    echo "
  • ";
  • Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn