Moze dla ułatwienia podam cały kod:
<?php
class Template {
public $strTemplateDir = './templates/2';
public $strBeginTag = '{';
public $strEndTag = '}';
public $arrVars = array();
private function __contruct() {}
public function assign( $strVar, $strValue ) {
$this->arrVars[$strVar] = $strValue;
}
public function display( $strFile ) {
$resFile = fopen( $this->strTemplateDir . '/' . $strFile, 'r' ); $strBuff = fread( $resFile, filesize( $this->strTemplateDir . '/' . $strFile ) ); foreach( $this->arrVars as $strVar => $strValue ) {
$strOutput = str_replace( $this->strBeginTag . '$' . $strVar . $this->strEndTag, $strValue, $strBuff ); }
}
}
$tpl = new Template;
$tpl->assign( 'Time', 'test' );
$tpl->assign( 'Dwa', 'test-2' );
$tpl->assign( 'Dwaq', 'test-2' );
echo $tpl->display( 'index.tpl' ); ?>