CURL中文乱码解决方案

WBOY
Release: 2016-06-13 12:55:11
Original
2586 people have browsed it

CURL中文乱码

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


$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");
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!