CURL replacement for file_get_contents


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



Copy this code and paste it in your HTML
  1. function file_get_contents_curl($url) {
  2. $ch = curl_init();
  3.  
  4. curl_setopt($ch, CURLOPT_HEADER, 0);
  5. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
  6. curl_setopt($ch, CURLOPT_URL, $url);
  7.  
  8. $data = curl_exec($ch);
  9. curl_close($ch);
  10.  
  11. return $data;
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.