Skip to content

Instantly share code, notes, and snippets.

@wookiecooking
Created May 14, 2013 03:38
Show Gist options
  • Save wookiecooking/5573494 to your computer and use it in GitHub Desktop.
Save wookiecooking/5573494 to your computer and use it in GitHub Desktop.
[PHP] Simple PHP OOP Curl
<?php
class get_contents {
public function url($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
}
$new = new get_contents();
$content = $new->url('http://www.google.com');
echo $content;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment