当前位置:Gxlcms > PHP教程 > CURL中文乱码解决方案

CURL中文乱码解决方案

时间:2021-07-01 10:21:17 帮助过:20人阅读

CURL中文乱码

$url = "http://www.gewara.com/cinema/ajax/getCinemaPlayItem.xhtml?cid=64915153&mid=&fyrq=2013-01-24";
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_exec($ch);
curl_close($ch);
?>


$url的时间请调整为当天或者明天~ 为什么会是乱码?
curl url php


------解决方案--------------------
header("content-type:text/html;charset=utf-8"); //指定下字符集
------解决方案--------------------
你写反了!

$contents = mb_convert_encoding($contents, "gb2312", "UTF-8");
不是
$contents = mb_convert_encoding($contents, "UTF-8", "gb2312");

人气教程排行