Quote
file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: php_network_getaddresses: getaddrinfo failed: Name or service not known
http://www.php-fangree.co.uk
<?php
$url = "http://www.php-fangree.co.uk";
$contents = @file_get_contents($url);
if ($contents){
echo "<span style='color: green;'> OK</span> ";
} else {
echo "<span style='color: red;'> NOT OK</span> ";
}
?>
function check_url($url) {
if(!filter_var($url, FILTER_VALIDATE_URL)) {
return "<span style='color: orange; font-size: 14px; font-weight: bold;'>URL provided wasn't valid</span>";
}
$ul = curl_init($url);
curl_setopt($ul, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ul, CURLOPT_HEADER, true);
curl_setopt($ul, CURLOPT_NOBODY, true);
curl_setopt($ul, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($ul);
curl_close($ul);
if ($resp)
return "<span style='color: green; font-size: 14px; font-weight: bold;'>Site seems to be up and running!</span>";
return "<span style='color: red; font-size: 14px; font-weight: bold;'>Oops nothing found, the site is either offline or the domain doesn't exist</span>";
}
$resp = check_url("http://www.fangree.com");
echo "<div class='resp'>".$resp."</div>";
Category Forum
General DiscussionLabels
None yet
Statistics
4 participants
Notifications
You are not receiving notifications from this thread.
Related Questions