Skip to content

Instantly share code, notes, and snippets.

@rodrigograca31
Last active June 29, 2016 14:54
Show Gist options
  • Save rodrigograca31/02715a89dc5dd840a75a to your computer and use it in GitHub Desktop.
Save rodrigograca31/02715a89dc5dd840a75a to your computer and use it in GitHub Desktop.
PHP CURL
<?
//From: http://php.net/manual/en/function.curl-exec.php
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "example.com");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//stop caching
$header = array("Cache-Control: no-cache");
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
var_dump($output);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment