Get Page Loading Time Using PHP
Thursday, Sep 28, 2017
Website loading speed is one of the major issue in site popularity generally and also very bad for seo users don't have patience if your website takes too much time to load then users does not want to wait for your website and by checking your website loading time you can see how much time your website takes to load helps to solve that problem. So, in this tutorial we will show you how to get page loading time using PHP. You may also like display progress bar while page loads.
InMotion 40% Discount And Free Domain With Every Shared Hosting Plan
Great news for Our Users! Now one of the best hosting provider InMotion offers 40% Discount And Free Domain With their Every Shared Hosting Plan. Hurry Up This Offer Is Very Limited And Only For Our Readers.
Click Here To Get This Offer !
To Get Page Load Time It Takes Only One Step:-
- Make a PHP file and define markup and scripting
Step 1.Make a PHP file and define markup and scripting
We make a PHP file and save it with a name page_load.php
<?php $start_time = microtime(TRUE); ?> <html> <body> <div id="wrapper"> <h1>Get Page Loading Time Using PHP</h1> Your WebPage Content </div> </body> </html> <?php $end_time = microtime(TRUE); $time_taken =($end_time - $start_time)*1000; $time_taken = round($time_taken,5); echo 'Page generated in '.$time_taken.' seconds.'; ?>
In this step we use PHP microtime() funtion to get time in starting place this code in starting of your webpage and then we again use same function to get time and the difference between both the starting time and ending time is the page load time place this code in end of your webpage to get correct page load time. You may also like display loading image while page loads.
That's all, this is how to get page loading time using PHP.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.
Hello, My Name is Mudit Jain. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of TalkersCode. I started this blog in february 2015 to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers.