What are the advantages and disadvantages of using existing template engines like Smarty compared to developing a custom template system in PHP?

Using existing template engines like Smarty can save time and effort in developing a custom template system from scratch. These engines often come with built-in features such as caching, template inheritance, and escaping functions. However, using a custom template system allows for more flexibility and control over the design and functionality of the templates.

// Example of using Smarty template engine
require_once('smarty/libs/Smarty.class.php');
$smarty = new Smarty;

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