What are some best practices for organizing PHP code to improve readability and maintainability, especially when mixing HTML and PHP?

When mixing HTML and PHP code, it's important to separate logic from presentation to improve readability and maintainability. One common practice is to use a template system like PHP's `include` or `require` functions to separate the HTML markup from the PHP logic. This helps keep the code organized and makes it easier to make changes to the layout without affecting the logic.

<?php
// Separate logic from presentation by including HTML templates
include('header.php');

// PHP logic here
echo '<p>Welcome, ' . $username . '</p>';

include('footer.php');
?>