Skip to content

Instantly share code, notes, and snippets.

@hamidhaghdoost
Created January 16, 2017 20:05
Show Gist options
  • Save hamidhaghdoost/e096dcfde17eadffe05f813dee3dcb37 to your computer and use it in GitHub Desktop.
Save hamidhaghdoost/e096dcfde17eadffe05f813dee3dcb37 to your computer and use it in GitHub Desktop.
php file_get_contents() with curl
<?php
function file_get_contents_curl( $url ) {
$ch = curl_init();
curl_setopt( $ch, CURLOPT_AUTOREFERER, TRUE );
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, TRUE );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
$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