Home  >  Article  >  Backend Development  >  php curl 提交参数中文乱码问题

php curl 提交参数中文乱码问题

WBOY
WBOYOriginal
2016-06-02 11:28:561724browse

phpcurl乱码

A站通过url形式POST数据注册B站,psot的中文,在B站是显示乱码的;
直接贴码:
$name="黄飞鸿";
$password="123456";
$get_url = "http://www.xxx.com/reg.php?name=".$name."&password=".$password
$row=getToken($get_url);

$obj=json_decode($row);

function getToken($url){
$ch = curl_init();
$this_header = array("content-type: application/x-www-form-urlencoded; charset=UTF-8");
curl_setopt($ch, CURLOPT_HTTPHEADER,$this_header);
curl_setopt($ch, CURLOPT_URL,$url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
return curl_exec($ch);
}

对方收到的name是乱码的;导致注册失败。
求大侠支招~

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