Skip to content

Instantly share code, notes, and snippets.

@DenverCoder1
Last active February 24, 2021 15:47
Show Gist options
  • Save DenverCoder1/0b7be8d132457222cbacdb1a8d21749a to your computer and use it in GitHub Desktop.
Save DenverCoder1/0b7be8d132457222cbacdb1a8d21749a to your computer and use it in GitHub Desktop.
<?php
// Get the contents of a URL
function curl_get_contents($url): string
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment