#7: Templating Your Site with Smarty

Most sites have a consistent look and feel. Although the dynamic content in the middle of the page may change, there's usually a header, a navigation bar on the side, and maybe an advertisement or two. There are simple ways to achieve this, from custom header-printing functions to include files. Depending on the size of your site, these solutions may work fine, but the larger and more complicated your content becomes, the more tedious making changes can get.

The most common templating solution is Smarty (http://smarty.php.net/). With Smarty, you create templates with variables. In other words, you can create one HTML file with placeholders for PHP-created data. In addition, you can include other Smarty templates ...

Get Wicked Cool PHP 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.