I want to get page status code.
Url address has a port and after that alias:
http://93.184.216.xxx:3000/status
I tried this this:
function status($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true); // we want headers
curl_setopt($ch, CURLOPT_NOBODY, true); // we don't need body
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpcode == 200) { return '<span class="green-link">ONLINE</span>';}
else {
return '<span class="red-link">'.$httpcode.'</span>';}
}
But this is useless, I'm always get status 0.
Can anybody have better idea? Thanks