網(wǎng)友原創(chuàng)的PHP模板類代碼
更新時間:2008年09月07日 10:29:36 作者:
學(xué)習(xí)php模板的朋友,可以參考下
復(fù)制代碼 代碼如下:
<?php
class Lightpage_Template {
var $Tpl_Header;
var $Tpl_Footer;
var $Tpl_Parsing;
var $Tpl_Template;
var $Tpl_Dirname;
var $Tpl_Parse_String;
var $Tpl_Parse_Array;
var $Tpl_Result;
function __construct() {
$this->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模板用法:
復(fù)制代碼 代碼如下:
$Mdl = new Lightpage_Template();
$Mdl->Tpl_Header = 'zzz';
$Mdl->Tpl_Footer = '';
$Mdl->Tpl_Parsing = '';
$Mdl->Tpl_Template = 'list.html';
echo $Mdl->Parse_Template();
相關(guān)文章
destoon在360瀏覽器下出現(xiàn)用戶被強(qiáng)行注銷的解決方法
這篇文章主要介紹了destoon在360瀏覽器下出現(xiàn)用戶被強(qiáng)行注銷的解決方法,需要的朋友可以參考下2014-06-06
關(guān)于DISCUZ不用通行證登陸得內(nèi)容介紹
DISCUZ是中國最常用的論壇,雖然他本身有通行證給大家連接,但實(shí)際上用戶的統(tǒng)一還是很不好,經(jīng)常要建立兩個用戶表,第一不利于注冊和管理,第二浪費(fèi)數(shù)據(jù)庫。2008-10-10
使用laravel和ECharts實(shí)現(xiàn)折線圖效果的例子
今天小編就為大家分享一篇使用laravel和ECharts實(shí)現(xiàn)折線圖效果的例子,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10
thinkPHP簡單導(dǎo)入和使用阿里云OSSsdk的方法
這篇文章主要介紹了thinkPHP簡單導(dǎo)入和使用阿里云OSSsdk的方法,簡單說明了阿里云OSS的php sdk下載地址及thinkPHP導(dǎo)入與使用OSSsdk的方法,需要的朋友可以參考下2017-03-03
Zend Framework入門教程之Zend_Db數(shù)據(jù)庫操作詳解
這篇文章主要介紹了Zend Framework入門教程之Zend_Db數(shù)據(jù)庫操作,結(jié)合實(shí)例形式詳細(xì)分析了Zend_Db_Adapter的功能及數(shù)據(jù)庫操作的相關(guān)技巧,需要的朋友可以參考下2016-12-12
php二維數(shù)組排序與默認(rèn)自然排序的方法介紹
本篇文章介紹了,在php中二維數(shù)組排序與默認(rèn)自然排序的方法。需要的朋友參考下2013-04-04

