哈哈,用exec执行系统的PING命令再分析,如何呢?希望有更好的办法。陪LZ一起等
解决方案 »
- 对一个PHP数组,获取前5个键值,怎么取值?达人进来看
- 自学PHP到会做个简单的贴吧程序要多长时间?
- 类似华军软件园、天空软件站,这样的软件下载站。
- PHP 执行外部程序等待的问题
- 求助各位大大:邮件的附件,上传后怎么处理?
- 请问如何读取WORD文档里的内容,用readfile()怎么不行?
- 急死人了,如何检测浏览者的IP?
- ODBC_CONNECT(或者mysql_connect)返回的数据库连接ID,能否通过Session传递使用?
- 请问各位大神,千万级商品量网站用什么系统好,
- PHP 怎么处理java webservice返回的字节流?
- php中关于HEADER的效率,达人请进
- 消除重复记录并统计的MSQYL问题
$size=1024*50;//这里你可以放大到*足够大*以确保数据能尽可能的接近真实
$callnumber=3;
$ip=$_SERVER[REMOTE_ADDR];
list($useca,$seca)=explode(" ",microtime());
@exec("ping -n $callnumber -l $size $ip",$data) or die("Support Forbid!");
list($usecb,$secb)=explode(" ",microtime());
$sec=$secb-$seca;
$msg=$data[count($data)-3];
list($drop,$info)=explode("(",$msg);
list($info,$drop)=explode("%",$info);
$spead=($size*$callnumber-$size*$callnumber*$info/100)/$sec;
echo sprintf("连接速度%.2f(k/s)",$spead/1024);
?>
但是如果服务器不允许ping,是不是就不准确了?大家还有什么其他好的办法吗?
你服务器到别人网站的速度有什么用啊
EXEC('PING')
划n个ip段,定时测试。也是一个解决方案。
----------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD> <BODY>
<script language=javascript>
tim=1
setInterval("tim++",100)
b=1var autourl=new Array()
autourl[1]="www.njcatv.net"
autourl[2]="javacool.3322.net"
autourl[3]="www.sina.com.cn"
autourl[4]="www.tominfo9.com"
autourl[5]="www.cctv.com"function butt(){
document.write("<form name=autof>")
for(var i=1;i<autourl.length;i++)
document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text name=url"+i+" size=40> =》<input type=button value=GO onclick=window.open(this.form.url"+i+".value)>");
document.write("<input type=submit value=刷新></form>")
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="链接超时"}
else
{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}
b++
}
function run()
{
for(var i=1;i<autourl.length;i++)
document.write("<img src=http://"+autourl[i]+"/"+Math.random()+" width=1 height=1 onerror=auto('http://"+autourl[i]+"')>")}
run()</script>
</BODY>
</HTML>
这个速度直接显示出来就是了。为什么要传给php?想自动使用最快的,也可以js直接实现跳转。