【问题标题】:PHP5 and smarty configuration problemsPHP5 和 smarty 配置问题
【发布时间】: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)。

标签: php smarty smarty3


【解决方案1】:

您的 PHP 代码看起来不错。

你应该清除你编译的模板目录,检查你的目录/文件权限,如果它没有帮助,事实上你不应该关心。这些警告是因为一些文件系统操作优化。

如果你想关闭它们,你可以使用:

$this->muteExpectedErrors();

在你的构造函数中(可能在调用父构造函数之后)。 Documentation on muteExpectedErrors

【讨论】:

    猜你喜欢
    • 2012-06-13
    • 1970-01-01
    • 2017-05-27
    • 2010-09-16
    • 1970-01-01
    • 2011-05-04
    • 2011-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多