Say I have this simple template.
Code: Select all
<html>
<head>
<title>{title}</title>
</head>
<body>
{body}
</body>
</html>
Code: Select all
<?php
//Include the template parser class file into our script
include "templateParser.php";
//Define our tags
$tags['title'] = "Hello";
$tags['body'] = "Hello World";
//output the page
$output = templateParser::parseTemplate($tags, "mytemplate.tpl");
echo $output;
?>
My main question is... is this approach, being procedural, any better or worse than going with a template parser that is object oriented in nature where you would use it something like this?
Code: Select all
<?php
//Include the template parser class file into our script
include "templateParser.php";
$template = new templateparser();
//Define our tags
$template->set_tag("title", "Hello");
$template->set_tag("body", "Hello World");
//output the page
$output = $template->render();
echo $output;
?>