600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > php简单的自定义模板类

php简单的自定义模板类

时间:2018-09-05 07:48:49

相关推荐

php简单的自定义模板类

php教程|php手册

php,简单,自定义,模板,类,php,class,MyTpl,private,template,dir,compi

php教程-php手册

class MyTpl {

private $template_dir;

private $compile_dir;

private $tpl_vars=array();

收费资源下载站源码,源码安装vscode,Ubuntu配置自定义网桥,Tomcat封装请求,sqlite视图优缺点,jq 虚拟键盘插件,用友前端用什么框架,网络爬虫爬取航空,php微信支付 扫码,神马seo,js开源项目网站,列表网页,单链表 模板,驱动程序 内存lzw

public function __construct($template_dir=”./templates”, $compile_dir=”./templates_c”){

$this->template_dir=rtrim($template_dir,”/”).’/’;

$this->compile_dir=rtrim($compile_dir, “/”).’/’;

}

无需登陆留言板源码,vscode设置行长标志,pppoe连接ubuntu,tomcat源码实现原理,sqlite3更改表的名称,同一网站不同页面爬虫如何解析,php 文章发布系统,搜狗seo推广前景,三合一网站cms,网页模板 图片csslzw

public function assign($tpl_var, $value=null){

if($tpl_var!=””)

$this->tpl_vars[$tpl_var]=$value;

}

笑话源码,怎么找到ubuntu分区,requests爬虫异常处理,php script,狗哥SEOlzw

public function display($fileName){

$tplFile=$this->template_dir.$fileName;

if(!file_exists($tplFile)){

return false;

}

$comFileName=$this->compile_dir.”com_”.$fileName.”.php”;

if(!file_exists($comFileName) || filemtime($comFileName) < filemtime($tplFile)){

$repContent=$this->tpl_replace(file_get_contents($tplFile));

file_put_contents($comFileName, $repContent);

}

include $comFileName;

}

private function tpl_replace($content){

$pattern=array(

‘/\/i’

);

$replacement=array(

‘tpl_vars[“${1}”]; ?>’

);

$repContent=preg_replace($pattern, $replacement, $content);

return $repContent;

}

}

?>

摘自:enough_br的专栏

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。