What are the benefits of using a template engine like Smarty in PHP development?

Using a template engine like Smarty in PHP development helps separate the presentation layer from the business logic, making the code more maintainable and easier to update. It also improves code readability and reusability by allowing developers to create reusable templates with dynamic content. Additionally, Smarty provides built-in security features to prevent common vulnerabilities like XSS attacks.

// Example PHP code snippet using Smarty template engine
require_once('smarty/libs/Smarty.class.php');

$smarty = new Smarty;

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