What are the benefits of using a template system in PHP for generating HTML output?

When generating HTML output in PHP, it can become messy and hard to maintain when mixing HTML code with PHP logic. Using a template system helps separate the presentation layer from the business logic, making the code more organized and easier to manage. Templates also allow for reusability of code and make it easier to make design changes without affecting the underlying logic.

```php
<?php
// Include the template file
include 'template.php';

// Define variables to be used in the template
$title = 'Welcome to our website';
$content = 'This is the content of the page';

// Include the template file and pass variables to it
include 'template.php';
?>
```

In the above code snippet, we are including a template file that contains the HTML structure of the page. We then define variables like `$title` and `$content` and pass them to the template file. This way, the HTML output is generated based on the variables passed to the template, keeping the logic separate from the presentation.