时时商务社区
标题:
网友原创的PHP模板类代码
[打印本页]
作者:
新格网络
时间:
2018-2-14 09:22
[U]复制代码[/U] 代码如下:
Tpl_Header = NULL;
$this->Tpl_Footer = NULL;
$this->Tpl_Parsing = array();
$this->Tpl_Template = 'list.html';
$this->Tpl_ToParse = NULL;
$this->Tpl_Parse_String = array();
$this->Tpl_Parse_Array = array();
$this->Tpl_Result = NULL;
return true;
}
function Parse_Template() {
$this->Tpl_Parse_String = array();
$this->Tpl_Parse_Array = array();
if($this->Tpl_Header!=NULL) { array_push($this->Tpl_Parse_String,$this->Tpl_Header);array_push($this->Tpl_Parse_Array,'{header}'); }
if($this->Tpl_Footer!=NULL) { array_push($this->Tpl_Parse_String,$this->Tpl_Footer);array_push($this->Tpl_Parse_Array,'{footer}'); }
if(count($this->Tpl_Parsing)!=1) {
foreach($this->Tpl_Parsing as $Tpl_Key => $Tpl_Value) {
array_push($this->Tpl_Parse_String,$Tpl_Value);
array_push($this->Tpl_Parse_Array,'{'.$Tpl_Key.'}');
}
}
if($this->Tpl_Template!=NULL && $this->Tpl_ToParse==NULL) {
$this->Tpl_ToParse = file_get_contents(root.'./Templates/'.$this->Tpl_Template);
}
$this->Tpl_Result = str_replace($this->Tpl_Parse_Array,$this->Tpl_Parse_String,$this->Tpl_ToParse);
return $this->Tpl_Result;
}
}
?>
php模板用法:
[U]复制代码[/U] 代码如下:
$Mdl = new Lightpage_Template();
$Mdl->Tpl_Header = 'zzz';
$Mdl->Tpl_Footer = '';
$Mdl->Tpl_Parsing = '';
$Mdl->Tpl_Template = 'list.html';
echo $Mdl->
arse_Template();
您可能感兴趣的文章:
php Http_Template_IT类库进行模板替换
用来解析.htgroup文件的PHP类
用来解析.htpasswd文件的PHP类
解析PHP汉字转换拼音的类
解析php类的注册与自动加载
PHP解析html类库simple_html_dom的转码bug
thinkphp模板输出技巧汇总
PHP模板引擎smarty详细介绍
PHP模板解析类实例
欢迎光临 时时商务社区 (http://bbs.4435.cn/)
Powered by Discuz! X3.2