Return to Snippet

Revision: 60103
at October 20, 2012 10:23 by o0110o


Initial Code
function file_content($_path) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
  curl_setopt($ch, CURLOPT_URL, $_path);
  $data = curl_exec($ch);
  curl_close($ch);
  return $data;
}

Initial URL


Initial Description
A handy function to get the contents of a file with curl. Accepts $_path as a parameter.

Initial Title
A function to get a files contents with curl.

Initial Tags
curl, php, function, files

Initial Language
PHP