Check net speed by loading a file : file_get_contents « File Directory « PHP






Check net speed by loading a file

 
<?php
   $data = file_get_contents("data.txt");

   $fsize = filesize("textfile.txt") / 1024;

   $start = time();

   $stop = time();

   $duration = $stop - $start;

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

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

?>
  
  








Related examples in the same category

1.Checking for an error from file_get_contents()
2.Fetching a URL with file_get_contents()
3.Reading a file into a string
4.file_get_contents.php
5.file_put_contents( ) writes to a file with the equivalent of fopen( ), fwrite( ), and fclose( ) all in one function, just like file_get_contents( ).
6.Use file_get_contents with a URL
7.Retrieving a protected page
8.Retrieving a remote page with file_get_contents()