Home > php教程 > php手册 > body text

php模拟ping命令的方法

WBOY
Release: 2016-06-21 08:49:18
Original
987 people have browsed it

本篇文章主要说下如何使用php模拟我们常用的DOS命令ping命令的方法,这里主要用到的是php的内置函数exec来调用系统的ping命令,从而实现ping命令功能的。

<?php $to_ping='www.Alixixi.com';
$count=2;
$psize=66;
echo "正在执行php ping命令,请等待...\n<br><br>";
flush();
while(1){
	echo "<pre class="brush:php;toolbar:false">";
	exec("ping -c $count -s $psize $to_ping", $list);
	for($i=0;$i<count print echo>";
	flush();
	sleep(3);
}</count>
Copy after login

注意使用exec函数必须需要服务器支持调用系统内置函数才行。另外也可以使用system等php内置函数来实现这个功能。



Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template