header('Content-type: text/html; charset=utf-8'); $ch = curl_init("http://stackoverflow.com/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $html = curl_exec($ch); curl_close($ch); var_dump($html); 

nothing var_dump is written to the html variable at all - bool (false), what could it be?

  • one
    CURL has curl_errno() , curl_error() , and curl_getinfo() . Than guessing, better see what they tell you. - neluzhin
  • couldn't connect to host - Denis Stepanyuk
  • And what resource do you want to open through CURL? - Arsen

2 answers 2

 curl_setopt($ch,CURLOPT_PROXY, false); 

here it is still necessary to add, it helped me

    curl_exec() returns false on failure: http://php.net/manual/ru/function.curl-exec.php#refsect1-function.curl-exec-returnvalues

    • check for errors using [ curl_errno() ] (http: // php.net/manual/ru/function.curl-errno.php) ( before closing by calling curl_close)
    • Log this code and error info with [ curl_error() ] (http: // php.net/manual/ru/function.curl-error.php) ( before closing by calling curl_close)
    • draw conclusions and appropriate changes :)

    from the example in the documentation:

     <?php // Создаем дескриптор curl к несуществующему адресу $ch = curl_init('http://404.php.net/'); // Запускаем curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); // Проверяем наличие ошибки if(curl_errno($ch)) { echo 'Ошибка curl: ' . curl_error($ch); } // Закрываем дескриптор curl_close($ch); ?>