I have some code to that should get the webpage from a supplied url. The urls will look something like this:
This is the code i have for fetching the page:
function GetHtmlContents($url){
echo $url;
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
echo "<br>";
echo $data;
}
but when i run this from my localhost the echo $data
is empty it doesnt show anything.
How do i fix this? This is my first time working with cURL.