How can comments in PHP code improve code readability and maintainability?

Comments in PHP code can improve code readability and maintainability by providing explanations for complex logic, documenting the purpose of functions or variables, and serving as reminders for future modifications. By including comments, developers can easily understand the codebase, make changes without breaking functionality, and collaborate effectively with team members.

// This function calculates the total price of items in the shopping cart
function calculateTotalPrice($items) {
    $totalPrice = 0;
    
    // Loop through each item and add its price to the total
    foreach ($items as $item) {
        $totalPrice += $item['price'];
    }
    
    return $totalPrice;
}