How to show page load time in PHP ?

If you need to calculate how much time elapsed during this the queries execute on the page.

The answer is:

$start = microtime(true);
$end = microtime(true);
printf("Page was generated in %f seconds", $end - $start);

For reference, microtime() in a PHP predefined function.

Write $start just before your query or the beginning of the page and $end at the end of all the queries or at the end of page.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.