What are the advantages and disadvantages of using templates in PHP for website development?

Using templates in PHP for website development can help separate the presentation layer from the business logic, making the code more organized and maintainable. Templates also allow for easier reuse of code and consistency in design across different pages. However, using templates can introduce some overhead in terms of performance and may require additional learning curve for developers.

<?php
// Example of using a template in PHP
$template = 'template.php';
$data = ['title' => 'Homepage', 'content' => 'Welcome to our website!'];

ob_start();
include $template;
$output = ob_get_clean();

echo $output;
?>