So I've seen some discussion here about pinging with php, but never the answer I'm looking for. Does anyone know of a way to ping from a php script without having to pass commands through to the system? As far as I know php has no support for ICMP. This is what I have been doing to get a ping time...
function ping($host) {
$ip=gethostbyname($host);
$result=ping -c 1 $ip;
$a=strpos($result, "time=");
$b=strpos($result, " ms");
if (!$a || !$b) {
return FALSE;
}
$a=$a+5;
$r=substr($result, $a, $b-$a);
return $r;
}
It seems stupid to have to do it this way. Suggestions?
-Mike