The way I see it, I could do it in 2 different ways:
1) Using the 'eval' function, making it possible to simply make some variables in the script and use those in the output, like this:
Code: Select all
<?php
$title = 'Testing Template System.';
echo eval($tpl->out('MAIN'));'
/* this is what is being returned by the eval:
<html>
<head>
<title>$title</title>
</head>
<body>
Stuff
</body>
</html>
*/
?>2) Replacing variables. I believe this is how most template engines work. I create an array (probably in the template class) which has all the data that goes into the HTML. Using functions like 'strtr' or 'str_replace' (I don't even know which function would be best for this) I would first replace certain code in the HTML with the variables before I output it.
I'm not sure which of those 2 methods would be best. If anyone could give me some tips on this, it would be much appreciated
Thanks.