欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

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

程序员文章站 2022-04-29 20:11:12
...
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 "";
	}
}
?>