ホームページ >バックエンド開発 >PHPチュートリアル >继承smarty类时遇到的有关问题,求指导!
继承smarty类时遇到的问题,求指导!!
我直接把smarty的libs目录拷进测试项目中,测试项目很简单,有两个文件demo.php和init.inc.php,然后我在init.inc.php做一些配置,比如界定符、模板目录之类,如果是以这种方式:
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php include_once './libs/Smarty.class.php'; $tpl=new Smarty; $tpl->left_delimiter="<!--{"; $tpl->right_delimiter="}-->";?>
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?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");?>
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> <?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'); } } ?>
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?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");?>