What are the recommended ways to format and structure PHP and JavaScript code for better readability and maintenance?

To improve readability and maintainability of PHP and JavaScript code, it is recommended to follow consistent coding standards, use proper indentation, and add comments to explain complex logic or functionality. Additionally, breaking down large chunks of code into smaller, more manageable functions can also help in organizing the code structure.

<?php

// Example of well-formatted PHP code
function calculateSum($num1, $num2) {
    // Add two numbers and return the result
    return $num1 + $num2;
}

$result = calculateSum(5, 10);
echo "The sum is: " . $result;

?>