I used cURL to get data from another website. Sometimes it shows data and sometimes empty result
Here is my Code
function get_data($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $agent=$_SERVER["HTTP_USER_AGENT"]; curl_setopt($ch,CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false); $data = curl_exec($ch); curl_close($ch); return $data; } $returned_content = get_data('www.example.com'); echo $returned_content;
curl_error($ch);
php.net/curl_error – gvgvgvijayanexit;
afterecho $returned_content
; – Ashwani Goyalwww.example.com
is not a URL, you are missing the protocol. – Daniel W.