Home  >  Article  >  Backend Development  >  php数据的编码问题

php数据的编码问题

WBOY
WBOYOriginal
2016-06-23 14:04:19982browse

想象某一网站post发送数据:

比如:
$postData = 'pai=' . urlencode('豫A5F666');

或者:
$postData=array( 'pai'=>urlencode('豫A5F666') );

希望得到的数据是 pai= %E8%B1%ABA5F666

但得到的确是: pai= %D4%A5A5F666

看来 urlencode函数是不行了,还有其他的办法吗?

查了很多资料,也无法解决,刚开始学php,谢谢啦~~~


回复讨论(解决方案)

$s = iconv('gbk', 'utf-8', '豫A5F666');
echo  urlencode($s); //%E8%B1%ABA5F666

$s = iconv('gbk', 'utf-8', '豫A5F666');
echo  urlencode($s); //%E8%B1%ABA5F666

谢谢版主哈,我把顺序搞反啦~~~

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