witam, mam taka klase:
<?php
class Template {
var $strTemplateDir = './templates/testowy';
var $strBeginTag = '{';
var $strEndTag = '}';
var $arrValues = array();
function assign( $strVar, $strValue ) {
$this->arrVars[] = $this->strBeginTag . $strVar . $this->strEndTag;
$this->arrValues[] = $strValue;
}
function display( $strFile ) {
$resFile = fopen( $this->strTemplateDir . '/' . $strFile, 'r' ); $strBuff = fread( $resFile, filesize( $this->strTemplateDir . '/' . $strFile ) ); $strTest = str_replace( $this->arrVars, $this->arrValues, $strBuff ); }
}
?>
wszystko dziala ok, ale chce zrobic mozliwosc podmiany templetow, i jak zrobie cos takiego:
<?php
$wybranystyl = \"testowy\";
class Template {
var $strTemplateDir = './templates/'.$wybranystyl; // tu jest cos nie tak
var $strBeginTag = '{';
var $strEndTag = '}';
var $arrValues = array();
function assign( $strVar, $strValue ) {
$this->arrVars[] = $this->strBeginTag . $strVar . $this->strEndTag;
$this->arrValues[] = $strValue;
}
function display( $strFile ) {
$resFile = fopen( $this->strTemplateDir . '/' . $strFile, 'r' ); $strBuff = fread( $resFile, filesize( $this->strTemplateDir . '/' . $strFile ) ); $strTest = str_replace( $this->arrVars, $this->arrValues, $strBuff ); }
}
?>
to wywala bledy :/