以下是一个简单的 PHP 脚本,可以使用它来批量 ping 检测 IP 地址或域名:


// 定义要 ping 的 IP 地址或域名
$hosts = array(
    'google.com',
    'facebook.com',
    'twitter.com',
    'linkedin.com',
    'github.com',
);

// 定义 ping 的次数
$count = 5;

// 遍历 IP 地址或域名进行 ping 测试
foreach ($hosts as $host) {
    echo 'Ping 测试 $host...
';

    // 执行 ping 命令并获取结果
    $command = 'ping -c $count $host';
    $output = shell_exec($command);

    // 输出 ping 结果
    echo $output;
}

?>

将上面的代码保存为一个 PHP 文件,然后使用命令行运行它,就可以批量 ping 检测指定的 IP 地址或域名了。注意,要在执行该脚本的服务器上安装 ping 命令。

PHP 批量 Ping 检测脚本:快速测试网站连通性

原文地址: https://www.cveoy.top/t/topic/nXiz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录