What are the advantages of using template engines like Smarty for separating PHP and HTML code?

When developing web applications, it is often beneficial to separate PHP logic from HTML presentation for better code organization and maintainability. Template engines like Smarty provide a way to achieve this separation by allowing developers to write template files with placeholders for dynamic content, which are then filled in by PHP code. This makes it easier to update the design of a website without needing to modify the underlying PHP logic.

<?php
require_once('smarty/Smarty.class.php');

$smarty = new Smarty;
$smarty->assign('name', 'John Doe');
$smarty->display('index.tpl');
?>