Skip to content

Show load time on page PHP

Sometimes in PHP, we want to show load time on the page where the script is executed. Here is the code snippet for that.

In Top of the page:

<?php
$start_time = microtime(TRUE);
?>

In Where do you want to display the loading time:

<?php
$end_time = microtime(TRUE);
$time_taken =($end_time - $start_time)*1000;
$time_taken = round($time_taken,1);
echo '<p class="text-right"><samp>Page generated in <mark>'.$time_taken.'</mark> seconds</samp></p>';
?>
See also  How to edit Laravel 5 Inspiring Quotes

Leave a Reply