ประมวลผลเวลาโหลดหน้าเว็บไซต์ Display page load time in PHP

Put the following code at the very top of your PHP page (if you measure the time needed for particular part of the code put this right before that PHP code part)
 

1
2
3
4
5
6
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
?>



The following code has to be put at the very end of the web page (or the end of the PHP code part)
 

1
2
3
4
5
6
7
8
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo 'Page generated in '.$total_time.' seconds.';
?>

Now, when you access your web page you will know the time needed for it to execute. This is an example output of what you are going to see:
Page generated in 0.0031 seconds. 

 

ที่มา 

https://www.phpjabbers.com/measuring-php-page-load-time-php17.html

http://www.botskool.com/geeks/display-page-load-time-php

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

PHP แสดง Error หลังนำลงใน Host

หากพบ.. Error ในหน้า php ของคุณประมาณด้านล่างนี้  Notice: Use of undefined constant visitor...