網(wǎng)友原創(chuàng)的PHP模板類(lèi)代碼
<?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)文章
PHP一個(gè)簡(jiǎn)單的無(wú)需刷新爬蟲(chóng)
今天小編就為大家分享一篇關(guān)于PHP一個(gè)簡(jiǎn)單的無(wú)需刷新爬蟲(chóng),小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2019-01-01基于thinkphp6.0的success、error實(shí)現(xiàn)方法
這篇文章主要介紹了基于thinkphp6.0的success、error實(shí)現(xiàn)方法,本文分步驟給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-11-11PHP下的浮點(diǎn)運(yùn)算不準(zhǔn)的解決方法
下面小編就為大家?guī)?lái)一篇PHP下的浮點(diǎn)運(yùn)算不準(zhǔn)的解決方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-10-10laravel5.6 框架郵件隊(duì)列database驅(qū)動(dòng)簡(jiǎn)單demo示例
這篇文章主要介紹了laravel5.6 框架郵件隊(duì)列database驅(qū)動(dòng),結(jié)合實(shí)例形式詳細(xì)分析了laravel5.6郵件隊(duì)列database驅(qū)動(dòng)具體設(shè)置、實(shí)現(xiàn)步驟與相關(guān)操作技巧,需要的朋友可以參考下2020-01-01PHP + plupload.js實(shí)現(xiàn)多圖上傳并顯示進(jìn)度條加刪除實(shí)例代碼
本篇文章主要介紹了PHP + plupload.js實(shí)現(xiàn)多圖上傳并顯示進(jìn)度條加刪除實(shí)例代碼。具有一定的參考價(jià)值,有興趣的可以了解一下。2017-03-03ThinkPHP框架中使用Memcached緩存數(shù)據(jù)的方法
這篇文章主要介紹了ThinkPHP框架中使用Memcached緩存數(shù)據(jù)的方法,結(jié)合實(shí)例形式分析了thinkPHP框架中Memcached緩存的設(shè)置與使用相關(guān)操作技巧,需要的朋友可以參考下2018-03-03使用PHP similar text計(jì)算兩個(gè)字符串相似度
在網(wǎng)站開(kāi)發(fā)中,我們經(jīng)常使用php similar text 計(jì)算兩個(gè)字符串相似度。本文涉及到similar text函數(shù)語(yǔ)法、用法詳解,感興趣的朋友一起學(xué)習(xí)吧2015-11-11laravel實(shí)現(xiàn)登錄時(shí)監(jiān)聽(tīng)事件,添加登錄用戶(hù)的記錄方法
今天小編就為大家分享一篇laravel實(shí)現(xiàn)登錄時(shí)監(jiān)聽(tīng)事件,添加登錄用戶(hù)的記錄方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09