Are there any best practices for structuring PHP code to avoid mixing HTML and PHP, as seen in the provided code snippet?

Mixing HTML and PHP code can make the code harder to read and maintain. To avoid this, it's recommended to separate the PHP logic from the HTML markup by using a templating system like PHP's built-in `include` function or a third-party template engine like Twig. By doing so, you can keep your PHP code clean and organized, making it easier to make changes to the HTML markup without affecting the logic.

<?php
// Separate PHP logic from HTML markup using include function
$data = ['name' => 'John Doe', 'age' => 30];
include 'template.php';
```

In the `template.php` file:

```html
<!DOCTYPE html>
<html>
<head>
    <title>Welcome</title>
</head>
<body>
    <h1>Welcome, <?php echo $data['name']; ?>!</h1>
    <p>Your age is <?php echo $data['age']; ?>.</p>
</body>
</html>