I have a list of URLs in an array and want to check how long it takes to access each webpage. Can you please tell me if it is possible to find a speed of a webpage using PHP? I would really appreciate it if you can show it to me with an example
If your web site runs entirely on php, you can measure how long the php script works. If you want to measure the response time of your server you can use firefox or chrome developer menu options which display the total access time to the server.
To measure the lifetime of a php script: The php function microtime() is a handy tool for time profiling. At the entry of your site add:
$startTime = microtime(true);
register_shutdown_function('measureTime');
function measureTime(){
global $startTime;
$execTime = microtime(true)-$startTime;
echo "Script execution time: $execTime seconds.";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With