Reusing a Header and Footer with PHP
Suppose the home and About pages have the same navigation and footer. Copying those sections works until you want to add a link and have to remember every page that contains a copy. A small PHP include puts each shared fragment in one place.
Create header.php with links to index.php and about.php. Put the shared closing text in footer.php. Then put this inside the body of both pages, changing the heading on the About page:
<?php include dirname(__FILE__) . '/header.php'; ?>
<h1>Home</h1>
<p>This is the content for this page.</p>
<?php include dirname(__FILE__) . '/footer.php'; ?>
Run both pages through a local PHP server. Add a link to the shared header and reload. The same link should now appear on both pages. If an include is missing, check the name and location of the file next to the page script. The example builds the path from the script’s directory and uses fixed filenames.
This is a small step toward templates. The page still owns its content, while shared pieces can change in one edit.