What are the limitations of using PHP to track the loading time of a webpage?

One limitation of using PHP to track the loading time of a webpage is that it only measures the server-side processing time and does not account for the time taken for client-side rendering. To overcome this limitation, you can use JavaScript to track the total loading time including client-side rendering.

<?php
$start_time = microtime(true);

// Your webpage content here

$end_time = microtime(true);
$total_time = $end_time - $start_time;
echo "Page loaded in " . $total_time . " seconds.";
?>