Skip to content

Instantly share code, notes, and snippets.

@jesseleite
Forked from Awea/gist:3487157
Last active February 9, 2023 07:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jesseleite/6181643 to your computer and use it in GitHub Desktop.
Save jesseleite/6181643 to your computer and use it in GitHub Desktop.
// cURL replacement for file_get_contents()
// Safer alternative to enabling allow_url_fopen in php.ini :)
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment