<BR><?php <BR>class Lightpage_Template { <br><br>var $Tpl_Header<i>·本2文来源gaodai$ma#com搞$代*码网2</i><strong>搞gaodaima代码</strong>; <BR>var $Tpl_Footer; <BR>var $Tpl_Parsing; <BR>var $Tpl_Template; <BR>var $Tpl_Dirname; <br><br>var $Tpl_Parse_String; <BR>var $Tpl_Parse_Array; <br><br>var $Tpl_Result; <br><br>function __construct() { <BR>$this->Tpl_Header = NULL; <BR>$this->Tpl_Footer = NULL; <BR>$this->Tpl_Parsing = array(); <BR>$this->Tpl_Template = 'list.html'; <BR>$this->Tpl_ToParse = NULL; <br><br>$this->Tpl_Parse_String = array(); <BR>$this->Tpl_Parse_Array = array(); <br><br>$this->Tpl_Result = NULL; <BR>return true; <BR>} <br><br>function Parse_Template() { <BR>$this->Tpl_Parse_String = array(); <BR>$this->Tpl_Parse_Array = array(); <BR>if($this->Tpl_Header!=NULL) { array_push($this->Tpl_Parse_String,$this->Tpl_Header);array_push($this->Tpl_Parse_Array,'{header}'); } <BR>if($this->Tpl_Footer!=NULL) { array_push($this->Tpl_Parse_String,$this->Tpl_Footer);array_push($this->Tpl_Parse_Array,'{footer}'); } <BR>if(count($this->Tpl_Parsing)!=1) { <BR>foreach($this->Tpl_Parsing as $Tpl_Key => $Tpl_Value) { <BR>array_push($this->Tpl_Parse_String,$Tpl_Value); <BR>array_push($this->Tpl_Parse_Array,'{'.$Tpl_Key.'}'); <BR>} <BR>} <BR>if($this->Tpl_Template!=NULL && $this->Tpl_ToParse==NULL) { <BR>$this->Tpl_ToParse = file_get_contents(root.'./Templates/'.$this->Tpl_Template); <BR>} <BR>$this->Tpl_Result = str_replace($this->Tpl_Parse_Array,$this->Tpl_Parse_String,$this->Tpl_ToParse); <BR>return $this->Tpl_Result; <BR>} <br><br>} <BR>?> <BR>
php模板用法:
<BR>$Mdl = new Lightpage_Template(); <BR>$Mdl->Tpl_Header = 'zzz'; <BR>$Mdl->Tpl_Footer = ''; <BR>$Mdl->Tpl_Parsing = ''; <BR>$Mdl->Tpl_Template = 'list.html'; <BR>echo $Mdl->Parse_Template(); <BR>