Just thought I would throw this out and see what replies I get back.
I am working on a open source PHP project that I started and I really wanted it to support templates. Templates are great for separating design from processing and allow themes to be created for sites without needing to alter the PHP code.
However, the choices seemed a little complicated for what I wanted. I really didn't want to get into the whole object oriented thing. I wanted it to be simple and understandable to anyone who has a very basic understanding of PHP.
This is what I ended up using.
It's basically a string replace system, but it works, and as we all know, that's the most important thing.
First we create a very simple template file(basic.tpl). This file can be named with really any extension, I use tpl just as a note to myself that it's a template file.
<html>
<body>
This site belongs to {owner_name}.
</body>
</html>
Next, we create the PHP file to read the template and produce the final output.
output.php
PHP Code:
<?php
$my_name = "Randy";
$html = implode('', file("basic.tpl"));
$html = str_replace("{owner_name}", $my_name, $html);
echo $html;
?>
Now when someone goes to output.php in the web browser they get this.
This site belongs to Randy.
Pretty simple, but effective.