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

tylerhall on 12/31/69


Tagged

curl get url fetch


Versions (?)


Who likes this?

8 people have marked this snippet as a favorite

luman
jkochis
millisami
irdial
vali29
hudge
benrasmusen
TheTiger


Fetch URL


Published in: PHP 


  1. function geturl($url)
  2. {
  3. $ch = curl_init();
  4. $timeout = 5;
  5. curl_setopt($ch, CURLOPT_URL, $url);
  6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  7. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  8. $html = curl_exec($ch);
  9. curl_close($ch);
  10. return $html;
  11. }

Report this snippet 

You need to login to post a comment.