How can Smarty templates be used to display content in PHP applications?

Smarty templates can be used in PHP applications to separate the presentation layer from the business logic. This allows for cleaner and more maintainable code by keeping HTML markup separate from PHP code. To use Smarty templates, you need to include the Smarty library in your project and then assign variables in your PHP code that can be accessed and displayed in the template.

// Include the Smarty library
require_once('libs/Smarty.class.php');

// Create a new Smarty object
$smarty = new Smarty();

// Assign variables to be displayed in the template
$smarty->assign('title', 'Welcome to my website');
$smarty->assign('content', 'This is some sample content to display');

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