What best practices should be followed when structuring PHP code for a dynamic website layout with menu navigation?

When structuring PHP code for a dynamic website layout with menu navigation, it is important to separate the logic from the presentation by using a template system such as PHP's include function. This allows for easier maintenance and updates to the layout. Additionally, using a database to store menu items and their corresponding URLs can make it easier to dynamically generate the menu navigation based on user permissions or other factors.

<?php
// Include the header template
include 'header.php';

// Query the database for menu items
$menuItems = [
    ['Home', '/'],
    ['About Us', '/about'],
    ['Services', '/services'],
    ['Contact', '/contact']
];

// Display the menu navigation
echo '<ul>';
foreach ($menuItems as $item) {
    echo '<li><a href="' . $item[1] . '">' . $item[0] . '</a></li>';
}
echo '</ul>';

// Include the footer template
include 'footer.php';
?>