How can proper indentation and formatting improve code readability and maintainability in PHP?

Proper indentation and formatting in PHP code can greatly improve readability and maintainability by making the code structure more clear and organized. It helps developers easily identify different code blocks, functions, and loops, making it easier to understand the logic of the code. Consistent indentation also helps in debugging and maintaining the code in the future.

<?php

// Badly formatted code
function calculateTotal($price,$quantity){
$total=$price*$quantity;
if($total>100){
echo "Total is greater than 100";
} else {
echo "Total is less than or equal to 100";
}
}

// Properly formatted code
function calculateTotal($price, $quantity) {
    $total = $price * $quantity;
    
    if ($total > 100) {
        echo "Total is greater than 100";
    } else {
        echo "Total is less than or equal to 100";
    }
}
?>