The original idea behind templating is fairly simple - if you abstract the code that displays content from the content itself, the end result is a cleaner, more simple site. This was the same thinking behind Cascading Style Sheets (CSS), in that CSS enabled you to take all the formatting and layout code embedded inside your HTML and place it into a separate file.

PHP itself was, in a way, just a template system at the very beginning of its life; its main purpose was to allow you create various types of content (guestbooks and other such web regulars) using special keywords and a limited command set.

Now that PHP is a full language in its own right, things have gone full circle - you can now create a template system in the language that used to be just a template system itself!


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: Templates ABC >>

Previous chapter: Calculating similarity of words

Jump to:


Home: Table of Contents

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