The results returned by php guzzle and curl are inconsistent.

first composer require guzzlehttp/guzzle

use GuzzleHttp\Client;
function curl_get($url)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_TIMEOUT, 3);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
    
     function guzzle_get($url)
    {
        $client = new Client();
        try {
            $tmp = $client->get($url,array("timeout"=>3,"connect_timeout"=>3)); 
            $res = strval($tmp->getBody());
        } catch (\Exception $e) {
            $res = "";
            
        }
        return $res;
    }
    
    $res = guzzle_get("http://i.hq.sinajs.cn/?list=sh600011,sh600012");
    // var hq_str_sh600011%2Csh600012="";\n
    $res = curl_get("http://i.hq.sinajs.cn/?list=sh600011,sh600012");
    // var hq_str_sh600011=",7.620,7.630,7.570,7.840,7.480,7.570,7.580,24252178,185351517.000,17372,7.570,65100,7.560,47600,7.550,19200,7.540,43200,7.530,31900,7.580,3300,7.590,46800,7.600,57580,7.610,9000,7.620,2018-09-19,15:00:00,00";var hq_str_sh600012=",5.490,5.500,5.570,5.610,5.470,5.560,5.570,3832663,21267001.000,89200,5.560,60100,5.550,32800,5.540,14500,5.530,29200,5.520,32328,5.570,74300,5.580,129500,5.590,114700,5.600,93300,5.610,2018-09-19,15:00:00,00";

what"s the difference between the two, and why does guzzle return an error?

Jul.07,2021

$tmp- > getBody ()-> can getContent () get the data?
if getContente () is also empty, try rewind () before getContent ()

$response- > getBody ()-> rewind ();
$data = $response- > getBody ()-> getContents ();


I haven't used guzzle either. You can take a look at the following document.

https://guzzle-cn.readthedocs.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea1e69-5c9ae.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea1e69-5c9ae.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?