Simple Template Class
<?
class Generate {
public $generate;
function load($filepath) {
$this->generate = file_get_contents($filepath);
}
function replace($var, $content) {
$this->generate = str_replace("#$var#", $content, $this->generate);
}
function publish() {
eval("?>".$this->generate."<?");
}
}
$Generate = new Generate;
$Generate->load("te,plate.php");
$Generate->replace("title", "Template Class");
$Generate->replace("name", "John");
$Generate->replace("datetime", date("m/d/y"));
$Generate->publish();
//Generate.php:
//<html>
//<head>
//<title>#title#</title>
//</head>
//<body>
//<h3>Hello #name#!</h3>
//<p>Time: #datetime#</p>
//<? echo "<p>OK!</p>"; ?>
//</body>
//</html>
//end
?>