php 怎么返回的是乱码呢?
程序员文章站
2024-01-23 19:35:10
...
以下是返回结果:
var hq_str_sh601006="������·,6.360,6.350,6.330,6.390,6.320,6.320,6.330,25996996,165270113.000,1055700,6.320,412700,6.310,524900,6.300,116900,6.290,131500,6.280,93700,6.330,340020,6.340,728100,6.350,668100,6.360,928814,6.370,2016-08-26,15:00:00,00";
以下是代码,也写了个编码了,怎么还是乱码呢?:
PHP实验-3
" ;
function getCurlData($url)
{
if (empty ( $url ))
{
return false;
}
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
$output = curl_exec ( $ch );
curl_close ( $ch );
return $output;
}
回复内容:
以下是返回结果:
var hq_str_sh601006="������·,6.360,6.350,6.330,6.390,6.320,6.320,6.330,25996996,165270113.000,1055700,6.320,412700,6.310,524900,6.300,116900,6.290,131500,6.280,93700,6.330,340020,6.340,728100,6.350,668100,6.360,928814,6.370,2016-08-26,15:00:00,00";
以下是代码,也写了个编码了,怎么还是乱码呢?:
PHP实验-3
" ;
function getCurlData($url)
{
if (empty ( $url ))
{
return false;
}
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
$output = curl_exec ( $ch );
curl_close ( $ch );
return $output;
}
最后改成 return iconv('gbk', 'UTF-8', $output);
就ok了吧 关键原来的是GBK的网页
~ ᐅ curl -I http://hq.sinajs.cn/list\=sh601006
HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 250
Connection: Keep-Alive
Content-Type: application/x-javascript; charset=GBK
原站是gbk
上一篇: 用PHP创建动态图形_PHP教程
推荐阅读
-
php 怎么返回的是乱码呢?
-
php的这是什么东东?怎么解决呢?求高手解决啊
-
PHP菜鸟 怎么提高开发的水平呢 平时要上夜大没多少时间
-
织梦中文分词 输入的词语返回乱码怎么处理
-
目前,网页脚本语言三个主流:PHP,JSP,.NET。究竟是一种怎么样的形势?是三国鼎立,还是其他的形势呢?各自的真正优势,又是在哪里?
-
php查询数据库的int字段,打印出来怎么是字符串类型呢?
-
【原创】我是怎么从零开始教女同学进行php开发的(4)
-
php-PHP怎么请求soap。其中要调用的那个方法的参数是这个方法的对象参数。到底该怎么调用
-
PHP读取mssql json数据中文乱码的解决办法 mssql2005数据库 mssql2008安装教程 mssql数据库是什
-
php 接收 shell 返回的结果后,中文乱码的解决办法