Home > php教程 > PHP源码 > PHP测试网速

PHP测试网速

PHP中文网
Release: 2016-05-25 17:13:55
Original
1962 people have browsed it

一段测试你网络速度的PHP

<?php

//$file = fopen(&#39;abc.txt&#39;,&#39;w&#39;);
//for($i=0;$i<170400;$i++) fwrite($file,&#39;helloworld&#39;);
//fclose($file);

$data = file_get_contents(&#39;abc.txt&#39;);
$fsize = filesize("abc.txt")/1024;

$start = gettime();

echo $data;

$end = gettime();

$cs = ($end[&#39;0&#39;]+$end[&#39;1&#39;]) - ($start[&#39;0&#39;]+$start[&#39;1&#39;]);

$speed = round(($fsize / $cs),2);

echo "
network: ".$speed." KB/sec.";


function gettime()
{
return explode(" ",microtime()); 
}
Copy after login

                   


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