php smarty模板引擎 性能,smarty性能低?直接使用php模板引擎吧
skymvc框架使用的php模板引擎
1.[代碼][PHP]代碼
class smarty{
public $template_dir = '';//模版文件夾
public $cache_dir = '';//緩存文件夾
public $compile_dir = '';//編譯文件夾
public $html_dir='';//生成靜態(tài)文件夾
public $htm_lfile="";
public function __construct(){
}
public function goAssign($tpl_var, $value = ''){
if(get('ajax')){
skymvc_test_page_auto();
C()->goALL("success",0,$tpl_var);
}else{
$this->assign($tpl_var,$value);
}
}
public function assign($tpl_var, $value = '')
{
if (is_array($tpl_var))
{
foreach ($tpl_var AS $key => $val)
{
if ($key != '')
{
$this->_var[$key] = $val;
}
}
}
else
{
if ($tpl_var != '')
{
$this->_var[$tpl_var] = $value;
}
}
}
public function display($filename, $cache_id = ''){
$out = $this->fetch($filename, $cache_id);
if(function_exists("shouQuanTpl")){
$out=shouQuanTpl($out);
}
if($this->html_file){
$this->umkdir(dirname($this->html_file));
file_put_contents($this->html_file,$out);
}
echo $out;
}
public function html($htmlfile,$expire=3600){
$file=$this->html_dir."/".$htmlfile;
$this->html_file=$file;
}
public function fetchhtml($str){
return $str;
}
public function fetch($filename, $cache_id = '',$dir=""){
ob_start();
extract($this->_var);
require $this->template_dir."/".$filename;
$out=ob_get_contents();
ob_end_clean();
return $out;
}
public function is_cached($filename, $cache_id = ''){
return true;
}
public function umkdir($dir){
mkdir($dir,0777,true);
}
}
?>
總結(jié)
以上是生活随笔為你收集整理的php smarty模板引擎 性能,smarty性能低?直接使用php模板引擎吧的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: matlab 摄像头拍照,matlab摄
- 下一篇: 中国的男明星有没有像007那样的神十的?