PHP code on curl -


this code not showing google home page. please point out error in it.

    <?php     $curl = curl_init();     curl_setopt($curl, curlopt_url, "https://www.google.com.kw");     curl_setopt($curl, curlopt_returntransfer, 1);     $result = curl_exec($curl);     curl_close($curl);     print $result;     ?> 

remember if response string-based; curl automatically encodes response in utf8. might necessary decode string want. otherwise, code ok here variant:

    <?php          $serviceurl = "https://www.google.com.kw";         $curl       = curl_init();          $settings   = array(             curlopt_url             => $serviceurl,             curlopt_post            => false,             curlopt_returntransfer  => true,         );          curl_setopt_array($curl, $settings);         $response   = curl_exec($curl);         $response   = utf8_decode ( $response );    // <== decodes utf8 encoded string.           if(curl_errno($curl)){             var_dump( curl_error($curl) );             exit;         }          print($response);          curl_close($curl); 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -