“ping” in PHP
Get your pinging result by PHP like this way:
—————————————–
< ?php
$arr = array();
exec("ping -c 2 www.google.com", $arr); //2 packets
dBug($arr);
function dBug($dump)
{
echo "<PRE>";
print_r($dump);
echo "</PRE>";
}
?>
—————————————–
I got this result:
—————————————-
Array
(
[0] => PING www.l.google.com (64.233.189.104) 56(84) bytes of data.
[1] => 64 bytes from 64.233.189.104: icmp_seq=0 ttl=245 time=608 ms
[2] => 64 bytes from 64.233.189.104: icmp_seq=1 ttl=245 time=519 ms
[3] =>
[4] => — www.l.google.com ping statistics —
[5] => 2 packets transmitted, 2 received, 0% packet loss, time 2755ms
[6] => rtt min/avg/max/mdev = 519.180/563.682/608.185/44.508 ms, pipe 2
)
—————————————-
Someones asked me this type of questions( related to checking connectivity by PHP). This one is my solution for now.
Regards,
[Rupom]
May 14th, 2006 at 12:49 pm
Good option to see ping result by php script.
September 24th, 2006 at 1:18 pm
Cool script. Actually PHP supports many efffective works with its simple functionality. But most of us donno the depth of uses for those functionality. Enjoy PHPing…..