What is the recommended method for maintaining a menu while dynamically changing content in PHP?

When dynamically changing content in PHP, the recommended method for maintaining a menu is to use include statements to separate the menu code into a separate file. This way, the menu can be included on every page without duplicating code. By doing this, any changes made to the menu will be reflected across all pages that include it.

// menu.php
<ul>
    <li><a href="index.php">Home</a></li>
    <li><a href="about.php">About</a></li>
    <li><a href="contact.php">Contact</a></li>
</ul>

// index.php
<?php include 'menu.php'; ?>
<h1>Welcome to the homepage</h1>

// about.php
<?php include 'menu.php'; ?>
<h1>About Us</h1>

// contact.php
<?php include 'menu.php'; ?>
<h1>Contact Us</h1>