Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. <?php
  2. function fetchUrl($url) {
  3. $allowUrlFopen = preg_match('/1|yes|on|true/i', ini_get('allow_url_fopen'));
  4. if ($allowUrlFopen) {
  5. return file_get_contents($url);
  6. } elseif (function_exists('curl_init')) {
  7. $c = curl_init($url);
  8. curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  9. $contents = curl_exec($c);
  10. curl_close($c);
  11. if (is_string($contents)) {
  12. return $contents;
  13. }
  14. }
  15. return false;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement