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

<?php

// 定义要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...\n";

    // 执行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/eGvn 著作权归作者所有。请勿转载和采集!

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