Why is it important to properly format and indent PHP code for readability and maintainability?
Properly formatting and indenting PHP code is important for readability and maintainability. It makes the code easier to understand for developers, which can lead to quicker debugging and modifications. Consistent formatting also helps maintain a clean and organized codebase, making it easier for multiple developers to collaborate on a project.
<?php
// Badly formatted code
function calculateTotal($price,$quantity){
$total=$price*$quantity;
return $total;
}
// Properly formatted code
function calculateTotal($price, $quantity) {
$total = $price * $quantity;
return $total;
}
?>