What are the best practices for structuring PHP scripts to avoid repetitive HTML code changes?

To avoid repetitive HTML code changes in PHP scripts, it is recommended to separate the HTML code from the PHP logic by using templates or including separate HTML files. This allows for easier maintenance and updates to the HTML code without having to modify the PHP scripts each time.

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

// Your PHP logic here

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