Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. This implies that PHP code is application logic, and is separated from the presentation.
How does it work?Under the hood, Smarty compiles copies of the templates as PHP scripts. This way you get the benefits of both template tag syntax and the speed of PHP. Compilation happens once when each template is first invoked, and then the compiled versions are used from that point forward. Smarty takes care of this for you, so the template designer just edits the Smarty templates and never has to manage the compiled versions. This approach keeps the templates easy to maintain, and yet keeps execution times extremely fast. Since the compiled versions are PHP, op-code accelerators such as APC or ZendCache continue to work on the compiled scripts.
Features: The template engine has many features for presentation that would otherwise need to be developed, tested and maintained in your own application code. Tags also mask the complexity of PHP statements.No different than PHP being an abstraction layer on top of C to simplify development, Smarty is an abstraction layer on PHP to simplify template maintenance.
The advantages of smarty are primarily based on the fact, that dynamic and static parts can be mixed up free, where the PHP code only needs to pass the required data to the Smarty template engine.
A complete isolation between the code which prepares the data and the one that creates the layout with smarty is achieved. The presentation can be completely changed this way without the need to change the application code.
Smarty can be extended by own plugins easily, which add special functionality to your system.
A lot of default tasks, like the creation of select-boxes and filtering of strings can be achieved more easily.