CURL replacement for file_get_contents

Easy way to CURL as easy as file_get_contents in PHP script.

function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}

Use it like show below

$data = file_get_contents_curl(‘http://webddr.net‘);

and you ready with whole website in variable $data. that’s all.

Category: Tips and Tricks
Tags:

Newer post:
Older post: