Posted By

o0110o on 10/20/12


curl php function files

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


A function to get a files contents with curl.

 / Published in: PHP

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

  1. function file_content($_path) {
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_HEADER, 0);
  4. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
  5. curl_setopt($ch, CURLOPT_URL, $_path);
  6. $data = curl_exec($ch);
  7. curl_close($ch);
  8. return $data;
  9. }

Report this snippet  

You need to login to post a comment.