calculate time php

Solutions on MaxInterview for calculate time php by the best coders in the world

showing results for - "calculate time php"
Bertram
14 Jun 2019
1//Calculate the execution time in PHP
2
3<?php 
4  
5// Start the clock time in seconds 
6$start_time = microtime(true); 
7$val=1; 
8  
9// Start loop 
10for($i = 1; $i <=99999; $i++) 
11{ 
12    $val++; 
13}  
14  
15// End the clock time in seconds 
16$end_time = microtime(true); 
17  
18// Calculate the script execution time 
19$execution_time = ($end_time - $start_time); 
20  
21echo " It takes ".$execution_time." seconds to execute the script"; 
22?>