Posted By

fackz on 12/04/10


Tagged

curl get data grab retrieve


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

fackz
muffminja


gets the data from a URL


 / Published in: PHP
 

  1. /* gets the data from a URL */
  2. function get_data($url)
  3. {
  4. $ch = curl_init();
  5. $timeout = 5;
  6. curl_setopt($ch,CURLOPT_URL,$url);
  7. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  8. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
  9. $data = curl_exec($ch);
  10. curl_close($ch);
  11. return $data;
  12. }
  13.  
  14. $returned_content = get_data('http://www.somedomain.com');
  15.  
  16. echo $returned_content;

Report this snippet  

You need to login to post a comment.