A function to get a files contents with curl.


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.