In what situations should one consider using a template engine like Smarty instead of directly embedding PHP code in templates?

When working on projects where designers or front-end developers need to work on the templates without having to deal with PHP code, using a template engine like Smarty can be beneficial. It helps separate the presentation layer from the business logic, making it easier to maintain and update the code. Additionally, template engines provide features like caching, template inheritance, and escaping variables to prevent security vulnerabilities.

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

$smarty = new Smarty;

// Assign variables to the template
$smarty->assign('name', 'John Doe');

// Display the template
$smarty->display('index.tpl');
?>