require_once 'smarty/Smarty.class.php'; $smarty = new Smarty; $smarty->display('template.tpl');
require_once 'smarty/Smarty.class.php'; $smarty = new Smarty; $smarty->assign('title', 'My Website'); $smarty->assign('content', 'Hello World!'); $smarty->display('template.tpl');
require_once 'smarty/Smarty.class.php'; $smarty = new Smarty; $smarty->assign('users', array( array('name' => 'John', 'age' => 25), array('name' => 'Jane', 'age' => 30), array('name' => 'Bob', 'age' => 35) )); $smarty->display('template.tpl');In this example, we have assigned an array of user data to the 'users' variable and then used a foreach loop in the template file to display each user's name and age. Smarty is a package library that can be easily installed and used with PHP applications to create dynamic content. It provides a wide range of features such as caching, template inheritance, and internationalization, making it a popular choice among developers.