The main question I have for you is, really, the differentiation between a template and the code that uses the template. As far as I can tell there are two different schools of thought on how each should be done:
The first one suggests that all the programming bits (namely the PHP) should be separate from the HTML, whereas the second (and the one I think makes more sense) is that all the logic code should be kept separate from the display code. There's a subtle difference between the two:
What constitutes as "logic code" will almost certainly be entirely PHP, as are the "programming" bits, so the two methods agree in this respect. The difference occurs when it comes to the templates themselves: the first suggestion implies that all PHP (so <?php ?> tags) should be in the programming bit, with a much simpler variable implementation system for using the variables set by the coding section directly to show what's needed. The second suggestion makes a strong differentiation between the language and the purpose. Logic code and display code are two different things from PHP and HTML.
Overall, I certainly agree with the second of the two, although the main disadvantage of it is the requirement for the template designer to have some knowledge of PHP. Is that such a bad thing, though? You don't have to know much, perhaps a bit of variable manipulation and looping? There is, of course, the other disadvantage that by allowing the person who works with the templates access to directly run PHP code, so that could potentially post a security risk. That said, if you trust someone enough to upload templates to your site, surely that's not really a problem. Similarly, if you're to do most of the work yourself it's equally not a problem.
Has anyone attempted to make a template engine before? If so, how did it go? If not, do you use another one, and have you had any luck with it?

