Skip to content

Instantly share code, notes, and snippets.

@alihalabyah
Created January 15, 2014 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save alihalabyah/8435482 to your computer and use it in GitHub Desktop.
Save alihalabyah/8435482 to your computer and use it in GitHub Desktop.
An alternative for file_get_contents() in PHP
<?php
public function url_get_contents ($url) {
if (!function_exists('curl_init')){
die('CURL is not installed!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment