0

这是我目前拥有的。它不起作用,需要做什么来解决它?

<?php
$status =  GetServerStatus('http://domain.com',80)
?>

<?php
function GetServerStatus($site, $port)
{
    $status = array("OFFLINE", "ONLINE");
    $fp = @fsockopen($site, $port, $errno, $errstr, 2);

    if (!$fp) {
        return $status[0];
    } else { 
        return $status[1];
    }
}
?>
4

1 回答 1

1

您没有输入 http:// 部分。

echo GetServerStatus('www.domain.com', 80);

function GetServerStatus($site, $port)
{
    $fp = @ fsockopen($site, $port, $errno, $errstr, 2);
    return ($fp)
        ? 'ONLINE'
        : 'OFFLINE';
}

Fist 参数应该是主机名而不是 URL。

于 2012-12-15T02:52:00.450 回答