Home  >  Article  >  Backend Development  >  URL接收的参数乱码,但是当地是正常的

URL接收的参数乱码,但是当地是正常的

WBOY
WBOYOriginal
2016-06-13 13:08:451067browse

URL接收的参数乱码,但是本地是正常的
http://localhost/xs7k/search/author-龙.html 就是正常的
这里有URL重写对应的为xs7k/search/index.php?type=$1&key=$2
本地获取key就是正常的,以前用bluehost的主要也是正常的

服务器上就不行了http://www.xs7k.com/search/author-龙.html,如这个。

今天换成国内的了iis的,能数只要是中文的就出错"??"显示成这个样子,请问有没有什么办法解决。

用$_REQUEST或$_GET都一样的。

------解决方案--------------------
$url="http://localhost/xs7k/search/".UrlEnCode('author-龙').".html";
先把中文编码一下再传$url这个变量试试.
如果urlencode这个编码不行的话你就用Base64_Encode编码,,不过用Base64_Encode的话需要用对应的解码函数解码一下才行.UrlEnCode就没有那么麻烦了.
------解决方案--------------------
不同浏览器传输中文的时候,字符集不同。有GBK的,也有UTF-8的。用urlencode一下,会比较妥当。
------解决方案--------------------
补充,我说的是在地址栏传输中文。
------解决方案--------------------
还是1楼的方法,你就直接取值的时候取转换完的值,比如php:alt="urlencode('龙')"JS:attr(alt)
------解决方案--------------------

探讨
我的这一句是从JS转过去的http://localhost/xs7k/search/author-龙.html

location.href='../search/'+type.options[type.selectedIndex].value+'-'+key.value+'.html';

在这里如果对key.value进行编码,PHP的不能用在这里的吧?
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