Get webpage load time in php

Hello friends. Want to know the page load time of your webpage. Here is a simple script to findout the page load time.

The code is divided into two blocks. You only have to include these two block of codes into your webpage. First at the top of your page and the second at the bottom of your page.

[ Include following at top of your page ]

  $time = microtime();
  $time = explode(" ", $time);
  $time = $time[1] + $time[0];
  $start = $time;

[ Your whole page contents/codes will be placed here ] 

[ Include following at bottom of your page ]

  $time = microtime();
  $time = explode(" ", $time);
  $time = $time[1] + $time[0];
  $finish = $time;
  $totaltime = ($finish - $start);
  echo "<!-- ";printf ($totaltime);echo "-->";



Run your page and view source code of your webpage.
You will see the last line commented. It is your page load time.

Thats it. Thanks !!
Get webpage load time in php Get webpage load time in php Reviewed by Altaf Hussain on 4:41 PM Rating: 5

No comments:

Altaf Web. Powered by Blogger.