What are some best practices for assigning and displaying data in Smarty templates in PHP?
When assigning and displaying data in Smarty templates in PHP, it is important to follow best practices to ensure clean and organized code. One common practice is to assign data to Smarty templates using the assign() method in PHP, and then display the assigned data in the template using the appropriate Smarty tags. It is also recommended to separate logic from presentation by keeping PHP code in the PHP files and template markup in the Smarty files.
```php
// Assigning data to Smarty template
$smarty->assign('name', 'John Doe');
$smarty->assign('age', 30);
// Displaying assigned data in Smarty template
$smarty->display('index.tpl');
```
In the Smarty template file (index.tpl), you can then access the assigned data using Smarty tags like {$name} and {$age}.