Smarty 异常:“请使用parent::__construct() 调用父构造函数”
我正在遵循教程,在设置完所有内容后我得到:
致命错误:未捕获异常“SmartyException”,消息为“请” 使用parent::__construct()调用父构造函数'
这是我的配置文件:
<?php
// SITE_ROOT contains the full path to the tshirtshop folder
define('SITE_ROOT', dirname(dirname(__FILE__)));
// Application directories
define('PRESENTATION_DIR', SITE_ROOT . '/presentation/');
define('BUSINESS_DIR', SITE_ROOT . '/business/');
// Settings needed to configure the Smarty template engine
define('SMARTY_DIR', SITE_ROOT . '/libs/smarty/');
define('TEMPLATE_DIR', PRESENTATION_DIR . 'templates');
define('COMPILE_DIR', PRESENTATION_DIR . 'templates_c');
define('CONFIG_DIR', SITE_ROOT . '/include/configs');
?>
我的目录结构是:
mydomain.com/test/include
mydomain.com/test/libs
mydomain.com/test/presentation
如何修复此错误?
I'm following a tutorial and after setting everything up I'm getting:
Fatal error: Uncaught exception 'SmartyException' with message 'Please
use parent::__construct() to call parent constuctor'
This is my config file:
<?php
// SITE_ROOT contains the full path to the tshirtshop folder
define('SITE_ROOT', dirname(dirname(__FILE__)));
// Application directories
define('PRESENTATION_DIR', SITE_ROOT . '/presentation/');
define('BUSINESS_DIR', SITE_ROOT . '/business/');
// Settings needed to configure the Smarty template engine
define('SMARTY_DIR', SITE_ROOT . '/libs/smarty/');
define('TEMPLATE_DIR', PRESENTATION_DIR . 'templates');
define('COMPILE_DIR', PRESENTATION_DIR . 'templates_c');
define('CONFIG_DIR', SITE_ROOT . '/include/configs');
?>
My directory structure is:
mydomain.com/test/include
mydomain.com/test/libs
mydomain.com/test/presentation
How can I fix this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这意味着有一个类扩展了 Smarty 类,它使用 __construct 方法,需要包含类似的内容:
这将调用 smarty 构造方法,如下所示:
This means there is a class extending the Smarty class that is using __construct method that needs to contain something like:
this will call the smarty construct method which looks something like this:
根据您的评论,您的 Application 类构造函数需要调用
parent::__construct()
,而不是parent::Smarty()
。From your comments, your Application class constructor needs to call
parent::__construct()
, notparent::Smarty()
.这个链接会很有帮助。
PHP4 识别 this->Smarty() 构造函数,PHP5 识别parent::__construct()。在 PHP5 中使用 this->Smarty() 时会发生错误。
this link will be helpful.
this->Smarty() constructor is recognized by PHP4 and parent::__construct() by PHP5. Error occurs when you use this->Smarty() in PHP5.