用php实现ping命令的方法

   用php实现ping命令的方法:
    实现方法其实很简单,主要使用php的内置函数exec来调用ping命令,从而实现ping的功能.也可以使用system等php内置函数,有兴趣的同学可以查看手册.实现代码如下:
    <?php
    $to_ping = “phpzixue.cn”;
    $count = 2;
    $psize = 66;
    echo “ Please be patient, this can take a few moments...\n<br><br>”;
    flush(); while (1) {
    echo “<pre>”;
    exec(“ping -c $count -s $psize $to_ping”, $list);
    for ($i=0;$i < count($list);$i++) {
    print $list[$i].“\n”;
    }
    echo “</pre>”;
    flush();
    sleep(3);
    }
    ?>