Home  >  Article  >  php教程  >  根据ping的返回值判断电脑是否在线

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

PHP中文网
PHP中文网Original
2016-05-25 17:11:031773browse


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 "";
	}
}
?>

                   

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn