<?php
class tplEngine{
protected $tpl_vars = array();//设置成属性便于全局赋值
public function assign($key,$val){
$this->tpl_vars[$key] = $val;
}
public function display($tpl){
if(!file_exists($tpl.".php")){
$html = file_get_contents($tpl);
$html = preg_replace('/\{\$(\w+)\}/','<?php echo $this->tpl_vars["\\1"]; ?>',$html);
file_put_contents($tpl.".php",$html);
}
include $tpl.".php";
}
}
class tplEngine{
protected $tpl_vars = array();//设置成属性便于全局赋值
public function assign($key,$val){
$this->tpl_vars[$key] = $val;
}
public function display($tpl){
if(!file_exists($tpl.".php")){
$html = file_get_contents($tpl);
$html = preg_replace('/\{\$(\w+)\}/','<?php echo $this->tpl_vars["\\1"]; ?>',$html);
file_put_contents($tpl.".php",$html);
}
include $tpl.".php";
}
}
2257

被折叠的 条评论
为什么被折叠?



