Templates ABC

The theory behind a basic template system is quite straightforward. A PHP developer, like yourself, creates a variety of flexible scripts to do various common jobs on your web site. These scripts, called templates, can be inserted by designers into HTML pages through the use of custom tags. During execution, these tags are replaced with the appropriate PHP scripts to form a complete page, and the effect is transparent to the end-user.

It is important to remember that templating systems are designed to make life easier for everyone. For the programmer, having a template system means they can set up the templates once and not really have to come back to them unless a serious change to the site design has been made. For the web designers (whom we will assume are non-programmers; think "Dreamweaver"), it means they have the ability to make use pre-written code without having to worry about whether it will work or not. That is, they can do that if you have done your part of the job properly!


Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: How do they work? >>

Previous chapter: Templates

Jump to:


Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.