What are some best practices for creating and maintaining templates for HTML files in PHP projects?

When working on PHP projects, creating and maintaining templates for HTML files can help streamline the development process and ensure consistency across pages. One best practice is to separate the HTML content from the PHP logic by using template files. This can be achieved by creating a separate file for the HTML structure and using PHP to inject dynamic content into the template.

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

// Dynamic content
$title = 'Welcome to our website!';
$content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';

// Include the main content template
include 'content.php';

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