【发布时间】:2014-08-22 08:15:46
【问题描述】:
我正在阅读入门 PHP 和 MySQL 电子商务。作者要求下载最新的 smarty 版本。书出版时是 smarty 2.x 现在是 3.x。 我将代码下载中的所有文件复制到我的文件夹中。我得到的错误是
Fatal error: Uncaught exception 'SmartyException' with message 'PHP5 requires you to call __construct() instead of Smarty()'
为了更正它,我将代码更改为
<?php
// Reference Smarty library
require_once SMARTY_DIR . 'Smarty.class.php';
/* Class that extends Smarty, used to process and display Smarty files */
class Application extends Smarty
{
// Class constructor
public function __construct()
{
// Call Smarty's constructor
parent::__construct();
// Change the default template directories
$this->template_dir = TEMPLATE_DIR;
$this->compile_dir = COMPILE_DIR;
$this->config_dir = CONFIG_DIR;
}
}
?>
我已经关注了以下链接 Fatal error: Uncaught exception 'SmartyException'
然后我得到了这个错误:
ERRNO: 2 TEXT: filemtime(): stat 失败 C:\xampp\htdocs\tshirtshop/presentation/templates_c\b34e4db7de306d57170626b504196f0c5fe34fa4.file.store_front.tpl.php 地点: C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_resource.php, 第 772 行,2014 年 8 月 22 日上午 9:59 显示回溯: filemtime("C:\xampp\htdocs\tshirtshop/presentation/templates_c\b34e4db7de30...") 第 772 行,文件:C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_resource.php Smarty_Template_Source.getCompiled(Object: Smarty_Internal_Template) # 第 699 行,文件: C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_template.php Smarty_Internal_Template.__get("compiled") # 第 154 行,文件: C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templatebase.php Smarty_Internal_TemplateBase.fetch("store_front.tpl", null, null, null, true) # 第 394 行,文件: C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templatebase.php Smarty_Internal_TemplateBase.display("store_front.tpl") # 第 16 行, 文件:C:\xampp\htdocs\tshirtshop\index.php
【问题讨论】:
-
你在 smarty 模板中做了什么?我认为这段代码没有任何问题(只是你应该使用 setter)。