PHP template class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
azizi
Forum Newbie
Posts: 1
Joined: Sat Oct 25, 2003 2:26 am
Location: Pakistan
Contact:

PHP template class

Post by azizi »

Hello every body,

i want to know that what is php template class and how can i use it to reduce my work...

hope u guys will guide me in details....

Regards,

Azizi
User avatar
Albright
Forum Newbie
Posts: 20
Joined: Sat Sep 13, 2003 8:03 pm
Contact:

Post by Albright »

I'm not sure exactly what you're asking, but if you're looking for a cool templating system, check out Smarty: http://smarty.php.net/

It's very extensible and very handy. It's a bit tricky to get started, but, like other aspects of programming, once you get used to it it's pretty simple.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Templating systems are a way to separate out the presentation layer - see http://www.phppatterns.com/index.php/ar ... ew/18/1/1/ for an intro to n-Tier.

Basically, a php script defines a bunch of vars, then these are echo'd out in a template. Presentation is controlled by the template and html is kept out of scripts. That makes for better programming in general and also allows html designers to do their thing without having to know any php.

A template could be a standard html file with a bunch of <?php echo $var; ?> statements.

In a template engine like smarty, custom placeholders are replaced with php when the template is parsed. Same sort of deal really - just slower.

Template engines do however have an important advantage in that you can prevent a designer from running php scripts. Not a problem for most of us but could be an issue on a large team project where privileges need to be restricted to the minimum.
Post Reply