What are some best practices for formatting and indenting PHP code for readability?

To improve the readability of PHP code, it is important to follow certain formatting and indenting best practices. One common approach is to use consistent indentation, typically with four spaces for each level of nesting. Additionally, using clear and descriptive variable names, breaking up long lines of code, and adding comments to explain complex logic can greatly enhance code readability.

<?php

// Example of well-formatted and indented PHP code
function calculateTotal($price, $quantity) {
    $subtotal = $price * $quantity;
    
    $taxRate = 0.08;
    $taxAmount = $subtotal * $taxRate;
    
    $total = $subtotal + $taxAmount;
    
    return $total;
}

$total = calculateTotal(10, 5);
echo "Total: $" . $total;

?>