首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Smarty报未找到createTemplate的异常

2014-01-01 
Smarty报未找到createTemplate的错误?Fatal error: Call to a member function createTemplate() on a non

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/';
}

?

,即在子类构造父类方法即可。

?

?

热点排行