网友原创的PHP模板类代码
2015-01-24信息快讯网
学习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();
phpmyadmin里面导入sql语句格式的大量数据的方法
php 智能404跳转代码,适合换域名没改变目录的网站
php中static静态变量的使用方法详解
php Static关键字实用方法
PHP var_dump遍历对象属性的函数与应用代码
Blitz templates 最快的PHP模板引擎
简化php模板页面中分页代码的解析
php单件模式结合命令链模式使用说明
php让图片可以下载的代码第1/2页
php 特殊字符处理函数
php include,include_once,require,require_once
php生成随机数或者字符串的代码
PHP通用分页类page.php[仿google分页]
需要使用php模板的朋友必看的很多个顶级PHP模板引擎比较分析
php模板之Phpbean的目录结构
深入解析php模板技术原理【一】
推荐php模板技术[转]
一个PHP模板,主要想体现一下思路