我只是在寻找php脚本检查服务器在线或OFfline为我的网站..在一个论坛上,我发现了以下脚本:
<?php
/* our simple php ping function */
function ping($host)
{
exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
return $rval === 0;
}
/* check if the host is up
$host can also be an ip address */
$host = 'XX.XX.XX.XX';
$up = ping($host);
/* optionally display either a red or green image to signify the server status */
if ($up) {
echo 'Online';
} else {
echo 'Offline';
}
?>我只想知道如何在同一脚本中ping多个IP?另外如何添加在线自柜台...?提前谢谢..
https://stackoverflow.com/questions/38460404
复制相似问题