We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

iloveitaly on 11/07/07


Tagged

curl php filegetcontents


Versions (?)


Who likes this?

5 people have marked this snippet as a favorite

vali29
heinz1959
agraddy
jaytee
jimmysessions


CURL replacement for file_get_contents


Published in: PHP 


  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 

You need to login to post a comment.