06-01-2008, 11:29 PM
|
#1 (permalink)
|
|
The Acquainted
Join Date: Sep 2007
Posts: 126
Thanks: 4
|
Template class - help!!
I have written the following simple class - first of all, if I can improve any parts, please let me know!!
PHP Code:
<?php
/**
* @author Sam Granger
* @copyright 2008, *******.com
*/
class Template {
var $template;
function __construct($template_file) {
$this->template = file_get_contents($template_file);
}
function replaceTags($variable, $content) {
$this->template = str_replace('<% ' . $variable . ' %>', $content, $this->template);
}
function displayHTML() {
echo $this->template;
}
}
?>
Used as following:
PHP Code:
$template = new Template('design.html');
$template->replaceTags('title', 'Hello!');
$template->replaceTags('message', 'Under construction');
$template->displayHTML();
Whats the best way to implement variables that are outputted from a while or for statement? 
|
|
|
|