Smarty报未找到createTemplate的错误
?
Fatal error: Call to a member function createTemplate() on a non-object in E:\__www__\MeltPHP.fw\htdocs\framework\extender\Smarty3\sysplugins\smarty_internal_templatebase.php on line 47
?
在用smarty做网页模板时,如果是继承smarty类开发的话,可能会出现以下错误
Fatal error: Call to a member function createTemplate() on a non-object in E:\__www__\MeltPHP.fw\htdocs\framework\extender\Smarty3\sysplugins\smarty_internal_templatebase.php on line 47
?
其原因是在继承Smarty类时,子类没有启用父类的构造函数,知道原因,解决方法就很简单了,如下
?
public?function?__construct()?{
????parent::__construct();
????$this->template_dir?=?'templates/';
????$this->compile_dir?=?'templates_c/';
????$this->config_dir?=?'configs/';
????$this->cache_dir?=?'cache/';
}?
,即在子类构造父类方法即可。
?
?