继承smarty类时遇到的问题,求指导!!
我直接把smarty的libs目录拷进测试项目中,测试项目很简单,有两个文件demo.php和init.inc.php,然后我在init.inc.php做一些配置,比如界定符、模板目录之类,如果是以这种方式:
<?php include_once './libs/Smarty.class.php'; $tpl=new Smarty; $tpl->left_delimiter="<!--{"; $tpl->right_delimiter="}-->";?>
<?php require_once 'init.inc.php'; $title="this is a title"; $content="this is my content"; $tpl->assign("title",$title); $tpl->assign("content",$content); $tpl->display("default/test.tpl");?>
<?php include_once './libs/Smarty.class.php'; class mySmarty extends Smarty{ function mySmarty(){ $this->Smarty(); $this->template_dir="./templates/"; $this->compile_dir="./templates_c/"; $this->config_dir="./configs/"; $this->cache_dir="./cache/"; $this->caching=true; $this->left_delimiter="<!--{"; $this->right_delimiter="}-->"; $this->assign('app_name','mySmartyTest'); } } ?>
<?php require_once 'init.inc.php'; $tpl=new mySmarty; $title="this is a title"; $content="this is my content"; $tpl->assign("title",$title); $tpl->assign("content",$content); $tpl->display("default/test.tpl");?>