Get Contents via cURL

, ,

So I have ran into an issue where a site was using URL's in the file_get_contents function and stopped working on the server.  This was also an issue if anyone was trying to do a URL include within a require() or an include(). Here was a solution that I found that worked well with cURL.

function get_content($URL){
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_URL, $URL);
      $data = curl_exec($ch);
      return $data;



Posted on

September 17, 2018

Submit a Comment

Your email address will not be published. Required fields are marked *