Smarty is a template engine designed with/for PHP. Smarty allows you to separate application logic from its presentation. This is ideal in team situations where you have coders and designers. It also means that if you wanted to redesign your site, you can do so without having to alter you PHP scripts.
The way it works is this: Your PHP script performs all necessary tasks and evaluations, gathers any necessary return data, and then assigns that data to the template for Smarty to have access to. From within your Smarty templates, you have placeholders for the variables that are assigned to it. Smarty has special tags that output the data from variables, arrays and objects, as well as allowing you to control how that data presentation is carried out.
Smarty uses special template tags along with HTML to display the content. Although the design goal of smarty is to separate application business logic from application presentation, it does allow certain logic for tasks such as looping over arrays, including other files, alternating table row colors and assigning values to variables from within your templates, plus much more.
Smarty is a very efficient template system in that it doesn't lose any speed to parsing overhead. All templates are compiled into native PHP the first time the template is run, and only again if the template file has been changed. This makes for a very efficient templating system.
We will now discuss how to set up and use Smarty in a simple example. First we will discuss how to set up the directory structure and necessary files. Then we will set up some simple examples to demonstrate how to use and access information from within your templates.