首頁  >  文章  >  php教程  >  根据ping的返回值判断电脑是否在线

根据ping的返回值判断电脑是否在线

PHP中文网
PHP中文网原創
2016-05-25 17:11:031816瀏覽


array("192.168.0.118","王五","行政",),
	"name4" =>array("192.168.0.140","李四","财务",),
	"name5" =>array("192.168.0.10","张三","后勤",),
	);

echo ""; 
echo "姓名"; 
echo "部门"; 
echo "状态"; 

foreach ($kkk as $ddd) {
	unset($result);
	exec("ping $ddd[0] -n 1",$result,$rval);
		
	if ($result[3] == $key){
		echo "\n";
		echo "$ddd[1]";
		echo "$ddd[2]";
		echo "离线";
		echo "";
	}else{
		echo "\n";
		echo "$ddd[1]";
		echo "$ddd[2]";
		echo "在线";
		echo "";
	}
}
?>

                   

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn