网友原创的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 相关文章推荐
PHP实现时间轴函数代码
Oct 08 PHP
php建立Ftp连接的方法
Mar 07 PHP
php计算两个日期相差天数的方法
Mar 14 PHP
php中判断数组相等的方法以及数组运算符介绍
Mar 30 PHP
Android App中DrawerLayout抽屉效果的菜单编写实例
Mar 21 PHP
php in_array() 检查数组中是否存在某个值详解
Nov 23 PHP
thinkphp3.2实现在线留言提交验证码功能
Jul 19 PHP
PHP闭包定义与使用简单示例
Apr 13 PHP
thinkPHP框架实现的无限回复评论功能示例
Jun 09 PHP
PHP实时统计中文字数和区别
Feb 28 PHP
PHP实现微信提现功能(微信商城)
Nov 21 PHP
如何在Laravel5.8中正确地应用Repository设计模式
Nov 26 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 加密与解密的斗争
2009/04/17 PHP
php返回字符串中所有单词的方法
2015/03/09 PHP
php实现将wav文件转换成图像文件并在页面中显示的方法
2015/04/21 PHP
PHP设计模式之工厂模式定义与用法详解
2018/04/03 PHP
一个很简单的jquery+xml+ajax的无刷新树结构(无css,后台是c#)
2010/06/02 Javascript
jQuery之按钮组件的深入解析
2013/06/19 Javascript
js Select下拉列表框进行多选、移除、交换内容的具体实现方法
2013/08/13 Javascript
JavaScript中的this关键字使用方法总结
2015/03/13 Javascript
常用的JQuery函数及功能小结
2016/03/24 Javascript
javascript弹出窗口中增加确定取消按钮
2016/06/24 Javascript
javascript加载xml 并解析各节点的值(实现方法)
2016/10/12 Javascript
各种选择框jQuery的选中方法(实例讲解)
2017/06/27 jQuery
vue v-for 使用问题整理小结
2019/08/04 Javascript
详解Vue串联过滤器的使用场景
2020/04/30 Javascript
Vue组件通信$attrs、$listeners实现原理解析
2020/09/03 Javascript
python定时采集摄像头图像上传ftp服务器功能实现
2013/12/23 Python
Python中用pycurl监控http响应时间脚本分享
2015/02/02 Python
利用Python获取操作系统信息实例
2016/09/02 Python
Python爬虫通过替换http request header来欺骗浏览器实现登录功能
2018/01/07 Python
Python基于百度AI的文字识别的示例
2018/04/21 Python
Python 实现Windows开机运行某软件的方法
2018/10/14 Python
详解Python requests 超时和重试的方法
2018/12/18 Python
Python+AutoIt实现界面工具开发过程详解
2019/08/07 Python
python实现通过flask和前端进行数据收发
2019/08/22 Python
Django和Flask框架优缺点对比
2019/10/24 Python
让你相见恨晚的十个Python骚操作
2020/11/18 Python
Get The Label中文官网:英国运动时尚购物平台
2017/04/19 全球购物
ghd官网:英国ghd直发器品牌
2018/05/04 全球购物
将时尚融入珠宝:Adornmonde
2019/10/17 全球购物
幼儿师范毕业生自荐信
2013/11/09 职场文书
《猴子种树》教学反思
2014/02/14 职场文书
班级心理活动总结
2014/07/04 职场文书
禁毒宣传活动总结
2014/08/26 职场文书
水电维修专业推荐信
2014/09/06 职场文书
2016年乡镇综治宣传月活动总结
2016/03/16 职场文书
python数字图像处理数据类型及颜色空间转换
2022/06/28 Python