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: PHP
Newer post: WordPress 3.0.4 Important Security Update
Older post: What To Do When Your Website Goes Down

Recent Feedback