EDIT : @fsockopen
을 사용하거나 실제로 확인하려고하는 내용이므로 무시할 수있는 경고 Cannot connect to the server
이 표시됩니다.
$ping = @fsockopen('myURL or IP', 80, $errno, $errstr, 10);
if (!$ping) // site is down
예컨대 :
<?php
$URL = 'randomurlfortestingpurposes.com';
$ping = @fsockopen ($URL, 80, $errno, $errstr, 10);
(!$ping) ? $status = $URL.' is down' : $status = $URL.' is up';
echo $status.'<br>';
$URL = 'google.com';
$ping = @fsockopen ($URL, 80, $errno, $errstr, 10);
(!$ping) ? $status = $URL.' is down' : $status = $URL.' is up';
echo $status;
?>
출력
randomurlfortestingpurposes.com is down
google.com is up
출처
2010-04-25 01:50:18
Ben
한 폐쇄 투표자가 말한 것처럼, 이것이 ServerFault에 속한다고는 말하지 않습니다. 서버가 온라인 상태인지 감지하는 방법을 프로그래밍하는 것입니다. 동사 "프로그래밍"은 명사 "서버"보다 우선합니다. – Matchu
하하, 누가 "태그"라는 태그를 만들었습니까? 매우 묘사적이다. –
@darren : 실제로 흥미로운 매크로 크로스 어셈블러가 그렇듯이. 어쨌든 그것이 태그의 기원이라고 생각합니다. – Joe