【问题标题】:Fatal error: Call to undefined method Smarty::Smarty()致命错误:调用未定义的方法 Smarty::Smarty()
【发布时间】:2018-07-21 13:33:09
【问题描述】:
<?php 
require_once  SMARTY_DIR . 'Smarty.class.php';
 class Application extends Smarty 
 {
   public function __construct()
   {
  parent::Smarty();
  $this->template_dir = TEMPLATE_DIR;
  $this->compile_dir = COMPILE_DIR;
  $this->config_dir = CONFIG_DIR;
   }
}
?>

我收到错误为致命错误:调用未定义的方法 Smarty::Smarty()
我在 php 项目文件夹中使用了 Smarty 软件 但我收到错误 我第一次在 php 中使用这个 Smarty 软件 我没有在这段代码中得到线索

【问题讨论】:

    标签: php smarty


    【解决方案1】:

    要调用父构造函数,你必须使用

      parent::__construct();
    

    而不是parent::Smarty();

    【讨论】:

    • 值得注意的是:parent::Smarty(); 可能在某一时刻有效。 PHP中的构造函数习惯于类的名称(因此Smartys构造函数实际上被命名为Smarty()。这个库已经足够老了,我愿意相信它曾经这样做过。我刚刚检查了github,它看起来当前版本或其向后兼容的包装器都不支持 PHP 4 样式语法。
    • @ArSen now new errro 警告:Smarty 错误:无法读取资源:第 1100 行 C:\xampp\htdocs\tshirtshop\libs\smarty\Smarty.class.php 中的“site.conf”
    • @Technicalstudieslogic 那么您可能缺少 smarty 的一些配置文件,如错误所示。见smarty.net/docs/en/config.files.tpl
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-14
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    • 2016-04-16
    • 2015-01-28
    • 2015-05-13
    相关资源
    最近更新 更多