<?php
function check_website_status($url) {
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($handle);
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
if ($httpCode >= 200 && $httpCode < 300) {
return "Website is up and running.";
} else {
return "Website is down with status code $httpCode.";
}
}
// Example usage:
$url = "https://www.example.com";
$status = check_website_status($url);
echo $status;
?>
Bu komut dosyası bir işlevi tanımlar check_website_status
Bu, giriş olarak bir URL alır ve web sitesinin yukarıda mı yoksa aşağıda mı olduğunu belirten bir mesaj döndürür. Değiştirebilirsin "https://www.example.com"
kontrol etmek istediğiniz web sitesinin URL'si ile.
Yorumlar (0)
Burada henüz yorum yok, ilk siz olabilirsiniz!