What are common methods for measuring script execution time in PHP?

Measuring script execution time in PHP is important for performance optimization and debugging. Common methods for measuring script execution time include using the microtime() function to capture the start and end times, and then calculating the difference to determine the total execution time.

// Start time
$start_time = microtime(true);

// Your PHP script here

// End time
$end_time = microtime(true);

// Calculate execution time
$execution_time = $end_time - $start_time;

echo "Script execution time: " . $execution_time . " seconds";