網(wǎng)友原創(chuàng)的PHP模板類代碼
更新時間:2008年09月07日 10:29:36 作者:
學習php模板的朋友,可以參考下
復制代碼 代碼如下:
<?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模板用法:
復制代碼 代碼如下:
$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)文章
基于thinkphp6.0的success、error實現(xiàn)方法
這篇文章主要介紹了基于thinkphp6.0的success、error實現(xiàn)方法,本文分步驟給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-11-11laravel5.6 框架郵件隊列database驅(qū)動簡單demo示例
這篇文章主要介紹了laravel5.6 框架郵件隊列database驅(qū)動,結(jié)合實例形式詳細分析了laravel5.6郵件隊列database驅(qū)動具體設置、實現(xiàn)步驟與相關(guān)操作技巧,需要的朋友可以參考下2020-01-01PHP + plupload.js實現(xiàn)多圖上傳并顯示進度條加刪除實例代碼
本篇文章主要介紹了PHP + plupload.js實現(xiàn)多圖上傳并顯示進度條加刪除實例代碼。具有一定的參考價值,有興趣的可以了解一下。2017-03-03ThinkPHP框架中使用Memcached緩存數(shù)據(jù)的方法
這篇文章主要介紹了ThinkPHP框架中使用Memcached緩存數(shù)據(jù)的方法,結(jié)合實例形式分析了thinkPHP框架中Memcached緩存的設置與使用相關(guān)操作技巧,需要的朋友可以參考下2018-03-03laravel實現(xiàn)登錄時監(jiān)聽事件,添加登錄用戶的記錄方法
今天小編就為大家分享一篇laravel實現(xiàn)登錄時監(jiān)聽事件,添加登錄用戶的記錄方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09