Template Systems

For some time now, PHP developers have been using different template systems to separate their PHP code (the logic of a page) from the HTML design (the look). The two popular methods were either included files—which I covered in Chapter 3, “Creating Dynamic Web Sites”—and object-oriented programming systems like FastTemplate.

The recently developed Smarty has dramatically improved upon these options by creating a template system that also compiles into static pages. In other words, the resulting HTML page can be made one time and then updated only as warranted by database changes. The further advantage of using Smarty is that it’s structured so that PHP logic can be placed within the template itself.

Smarty is an official part ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.