curl_exec printing results when I don't want to

前端 未结 3 666
广开言路
广开言路 2020-12-04 23:18

I am using the following code:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_TIMEOUT, 12); 

$result = curl_exec($ch);

         


        
3条回答
  •  误落风尘
    2020-12-04 23:52

    after php 5.1 curl will display always result you can view in documentation. for avoid it simply use

    echo "< span style='display:none'>";
    
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, $url);
    
    curl_setopt($ch, CURLOPT_TIMEOUT, 12);
    
    $result = curl_exec($ch);
    
    curl_close ($ch);
    
    echo"< /span>";
    

提交回复
热议问题