Bob*_*Bob 3 php runtime-error smarty
我正在关注一个教程,在设置完所有内容后,我得到了:
致命错误:未捕获异常'SmartyException',消息'请使用parent :: __ construct()来调用父constuctor'
这是我的配置文件:
<?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');
?>
Run Code Online (Sandbox Code Playgroud)
我的目录结构是:
mydomain.com/test/include
mydomain.com/test/libs
mydomain.com/test/presentation
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个错误?
小智 7
这意味着有一个类使用__construct方法扩展Smarty类,该方法需要包含以下内容:
public function __construct() {
parent::__construct();
}
Run Code Online (Sandbox Code Playgroud)
这会调用smarty构造方法,看起来像这样:
public function __construct()
{
// selfpointer need by some other class methods
$this->smarty = $this;
if (is_callable('mb_internal_encoding')) {
mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET);
}
$this->start_time = microtime(true);
// set default dirs
$this->template_dir = array('.' . DS . 'templates' . DS);
$this->compile_dir = '.' . DS . 'templates_c' . DS;
$this->plugins_dir = array(SMARTY_PLUGINS_DIR);
$this->cache_dir = '.' . DS . 'cache' . DS;
$this->config_dir = '.' . DS . 'configs' . DS;
$this->debug_tpl = SMARTY_DIR . 'debug.tpl';
if (isset($_SERVER['SCRIPT_NAME'])) {
$this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4747 次 |
| 最近记录: |