Answer the question
In order to leave comments, you need to log in
Website accessibility check, how to check several?
Hello.
There is a script which checks availability of the server.
function isDomainAvailible($domain)
{
//проверка на валидность урла
if(!filter_var($domain, FILTER_VALIDATE_URL))
{
return false;
}
//инициализация curl
$curlInit = curl_init($domain);
curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($curlInit,CURLOPT_HEADER,true);
curl_setopt($curlInit,CURLOPT_NOBODY,true);
curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);
//получение ответа
$response = curl_exec($curlInit);
curl_close($curlInit);
if ($response) return true;
return false;
}
?>
Answer the question
In order to leave comments, you need to log in
Call the function as many times as you like, you can for convenience in a loop or simply, in order:
isDomainAvailible('http://site1.ru');
isDomainAvailible('http://site2.ru');
Pass multiple domains to the function.
For example, there is an array of 2 sites array('site1','site2');
Just pass the values of the array in the loop
<?php
$domain = array('http://butsw.pp.ua/', 'http://google.com/', 'http://gryazniepisyuni.com/');
foreach ($domain as $url) {
$is = isDomainAvailible($url);
if ($is == 1) {
echo "OK! <br>";
} else {
echo "ERR!!!<br>";
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question