PHP curl returns error: Couldn't resolve host 'www.xxx.com'. How can I solve this?
<p>this function returns null and prints error :</p>

<p>Couldn't resolve host 'www.xxx.com'</p>

<pre><code>function file_get_html_using_cURL($url) {
    if (!function_exists('curl_init')){ 
        die('CURL is not installed!');
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $output = curl_exec($ch);
    if(curl_errno($ch)){
        echo 'Curl error: ' . curl_error($ch);
        echo "\n--------------------\n";
        print_r(curl_getinfo($ch));
        echo "\n--------------------\n";
    }
    $output = str_get_html($output); // &lt;-- Important line to convert string into object!
    curl_close($ch);
    return $output;
}
</code></pre>

<p>When I load this code in localhost, it works. But it throws the error when I upload it to the remote server. </p>

<p>I  am guessing that the remote server has blocked CURL from executing. </p>

<p>It's a free server so I can't change any settings in php.ini</p>

<p>Is there any way around this?</p>

<p>P.S. </p>

<pre><code>file_get_content($url)
</code></pre>

<p>is blocked as well. So I tried using curl instead. But not curl doesn't seem to work anymore.</p>