Smarty template engine

Smarty is a template engine for PHP. More specifically, it facilitates a manageable way to separate application logic and content from its presentation.
Benefits of using Smarty template engines:
1. separates code from HTML.
2. When you get used to using template engines, your applications will be developed faster
3. Your source code will be more organized, more clean and easier to understand
4. Teamwork is a lot easier.
Web page designers are not dealing with PHP code syntax, but instead easy-to-use templating syntax not much different than plain HTML. The templates are a very close representation of the final output, dramatically shortening the design cycle.

Code example

Since Smarty separates PHP from HTML, you have two files:

Follow the steps:
Step1:
1.Download Latest Stable Release Smarty here
2. create two directory in www or htdoces named templates and temp
3. create a html file named test.html in templates dir
4. create a php file named test.php in root dir(i.e,www/htdocs)
step 2:
paste the following codes in test.html file

step 3:
paste the following codes in test.php file

Now browse test.php
output of this script will be…
This is the Smarty basic example.

References:
http://en.wikipedia.org/wiki/Smarty
http://tech.gogic.co.yu/web-development/smarty-template-engine/
http://www.fanphp.com/category/smarty/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: