www.netcreator.us
NETCreator - News, Scripts, Hosting, CMS, Tutorials

How to show page generation and execution time in PHP

PHP & Programming Languages - NETCreator - 2016-04-01 12:56:42

There are two methods of displaying the page generation time in PHP.

Old PHP versions can do this as below:

$time_start = microtime(true);
// Write your code here...
$time_end = microtime(true);
$gen_time = $time_end - $time_start;
echo "This page has been generated in: {$gen_time} seconds.";

As of PHP 5.4.0 you can simply do this as below (put this at the end of file):

$gen_time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
echo "This page has been generated in: {$gen_time} seconds.";
Latest Posts
NETCreator CMS

Search
Free Hosting