I am explaining you, how to check website availability/online with use of PHP and Curl. you can check if website is online/available in PHP. It uses PHP and cURL code. after check website’s status we can define it is online/available or not.
<?php
function OnlineCheckWebSiteUrl($url){
if(!filter_var($url, FILTER_VALIDATE_URL)){
return false;
}
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($ch,CURLOPT_HEADER,true);
curl_setopt($ch,CURLOPT_NOBODY,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$response = curl_exec($ch);
curl_close($ch);
return $response ? true : false;
}echo "<br>";
$url = 'https://webdeveloperindia.in';
if(OnlineCheckWebSiteUrl($url)){
echo 'Yes, website`s url is available/online';
}else{
echo 'The web site is not available/online';
}
?>
Output :
Yes, website`s url is available/online
Hello, Welcome to webdeveloperindia.in. I am a full-stack web developer. Email – [email protected] | Skype – azaruddin23. I have knowledge of PHP, Laravel, Magento 1/2, Codeigniter, WordPress, Joomla, Shopify, Git, Bitbuket, jQuery, Ajax, Javascript and ReactJS.