gets the data from a URL


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



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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.