How does php return garbled characters?

Source: Internet
Author: User
The following is the returned result: {code...} The following is the code and the code is also written. why is it garbled? : {Code...} The following is the returned result:

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"; 

The following is the code and the code is also written. why is it garbled? :

        
      PHP lab-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 ;}

Reply content:

The returned results are as follows:

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"; 

The following is the code and the code is also written. why is it garbled? :

        
      PHP lab-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 ;}

Last changed return iconv('gbk', 'UTF-8', $output);Okay. The key is the GBK web page.

~   ᐅ curl -I http://hq.sinajs.cn/list\=sh601006HTTP/1.1 200 OKCache-Control: no-cacheContent-Length: 250Connection: Keep-AliveContent-Type: application/x-javascript; charset=GBK

The original site is gbk

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.