网友原创的PHP模板类代码


Posted in PHP onSeptember 07, 2008
<?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();
PHP 相关文章推荐
web方式ftp
Oct 09 PHP
图书管理程序(二)
Oct 09 PHP
杏林同学录(七)
Oct 09 PHP
PHP define函数的使用说明
Aug 27 PHP
PHP中替换键名的简易方法示例详解
Jan 07 PHP
php实现aes加密类分享
Feb 16 PHP
PHP获取一个字符串中间一部分字符的方法
Aug 19 PHP
php短址转换实现方法
Feb 25 PHP
php等比例缩放图片及剪切图片代码分享
Feb 13 PHP
php文件管理基本功能简单操作
Jan 16 PHP
laravel5.4利用163邮箱发送邮件的步骤详解
Sep 22 PHP
PHP PDOStatement::getColumnMeta讲解
Feb 01 PHP
php 特殊字符处理函数
Sep 05 #PHP
php include,include_once,require,require_once
Sep 05 #PHP
php生成随机数或者字符串的代码
Sep 05 #PHP
PHP通用分页类page.php[仿google分页]
Aug 31 #PHP
php将数据库中的电话号码读取出来并生成图片
Aug 31 #PHP
PHP生成HTML静态页面实例代码
Aug 31 #PHP
php array_slice函数的使用以及参数详解
Aug 30 #PHP
You might like
php中的时间显示
2007/01/18 PHP
PHP中文汉字验证码
2007/04/08 PHP
php获取目录所有文件并将结果保存到数组(实例)
2013/10/25 PHP
PHP自带ZIP压缩、解压缩类ZipArchiv使用指南
2015/03/03 PHP
Linux安装配置php环境的方法
2016/01/14 PHP
php的闭包(Closure)匿名函数初探
2016/02/14 PHP
php5.2的curl-bug 服务器被php进程卡死问题排查
2016/09/19 PHP
PHP正则表达式匹配替换与分割功能实例浅析
2017/02/04 PHP
Laravel中批量赋值Mass-Assignment的真正含义详解
2017/09/29 PHP
CodeIgniter框架数据库基本操作示例
2018/05/24 PHP
IE的有条件注释判定IE版本详解(附实例代码)
2012/01/04 Javascript
js调用css属性写法
2013/09/21 Javascript
jquery根据属性和index来查找属性值并操作
2014/07/25 Javascript
jQuery实现的选择商品飞入文本框动画效果完整实例
2016/08/10 Javascript
BootStrap日期控件在模态框中选择时间下拉菜单无效的原因及解决办法(火狐下不能点击)
2016/08/18 Javascript
深入理解Commonjs规范及Node模块实现
2017/05/17 Javascript
vue中使用props传值的方法
2019/05/08 Javascript
探索浏览器页面关闭window.close()的使用详解
2020/08/21 Javascript
[01:21]辉夜杯战队访谈宣传片—CDEC
2015/12/25 DOTA
Python 登录网站详解及实例
2017/04/11 Python
使用tensorflow实现AlexNet
2017/11/20 Python
利用python 更新ssh 远程代码 操作远程服务器的实现代码
2018/02/08 Python
对python中的乘法dot和对应分量相乘multiply详解
2018/11/14 Python
Django框架实现的简单分页功能示例
2018/12/04 Python
Python爬取视频(其实是一篇福利)过程解析
2019/08/01 Python
屏蔽Django admin界面添加按钮的操作
2020/03/11 Python
python 读txt文件,按‘,’分割每行数据操作
2020/07/05 Python
Python爬取数据并实现可视化代码解析
2020/08/12 Python
python 多线程共享全局变量的优劣
2020/09/24 Python
如何利用CSS3制作3D效果文字具体实现样式
2013/05/02 HTML / CSS
CSS3中Transition动画属性用法详解
2016/07/04 HTML / CSS
英国领先的维生素和营养补充剂直接供应商:Healthspan
2019/04/22 全球购物
业务内勤岗位职责
2014/04/30 职场文书
倡议书格式模板
2014/05/13 职场文书
员工三分钟演讲稿
2014/08/19 职场文书
大学生读书笔记范文
2015/07/01 职场文书