I am trying to check whether a certain domain is live or not. My idea is to read the content with file_get_contents(), and check whether it succeed or failed.
$line = file_get_contents('http://www.domain.com');
if ($line==false)
echo 'Domain is dead';
else
echo 'Domain is live';
The problem I am having is that when it fails, it outputs a warnings on the web page. Turning off all warnings via the PHP config is not an option cause I need them on some other parts. Is there a way to make this single statement not output a warning?
Or is there a better way to check if a domain is live? I tried checkdnsrr() but it was pretty slow.