PHP致命错误:类';SmartySecurity';找不到

PHP致命错误:类';SmartySecurity';找不到,php,smarty,smarty3,Php,Smarty,Smarty3,在为那个旧网站升级Smarty 2.6到Smarty 3.1的过程中,我花了两个小时的时间。原因是主机现在仅为PHP7。不再使用PHP5。我原以为这是一个1小时的交易,但很快就变成了一场噩梦。我记得2005年使用Smarty时,我再也没有使用过它,但在将近15年后的今天,这个巨大的模板引擎又在困扰着我 以下是init PHP文件的内容: <?php #Load Smarty library #require_once("php/Smarty-2.6.26/libs/Smarty.clas

在为那个旧网站升级Smarty 2.6到Smarty 3.1的过程中,我花了两个小时的时间。原因是主机现在仅为PHP7。不再使用PHP5。我原以为这是一个1小时的交易,但很快就变成了一场噩梦。我记得2005年使用Smarty时,我再也没有使用过它,但在将近15年后的今天,这个巨大的模板引擎又在困扰着我

以下是init PHP文件的内容:

<?php

#Load Smarty library
#require_once("php/Smarty-2.6.26/libs/Smarty.class.php");
#require_once("php/smarty-3.1.34/libs/Smarty.class.php");
require_once("php/smarty-3.1.34/libs/SmartyBC.class.php");
require_once("php/smarty-3.1.34/libs/sysplugins/smarty_security.php");

class class_init extends SmartyBC {

    function __construct(){
        #Init
        parent::__construct();

        #Directories
        $this->template_dir = "skin/".SKIN."/public/";
        $this->compile_dir  = "skin/".SKIN."/compile/";
        $this->config_dir   = "skin/".SKIN."/config/";
        $this->cache_dir    = "skin/".SKIN."/cache/";

        #Caching
        $this->caching          = (boolean)SMARTY_CACHING;
        $this->cache_lifetime   = (int)SMARTY_CACHE_LIFETIME;
        $this->debugging        = true;
    }

    function is_cached($str_tpl, $cache_id = NULL, $compile_id = NULL){
        return $this->isCached($str_tpl, $cache_id, $compile_id);
    }
}

class MySecurity extends SmartySecurity {
    public $secure_dir = array('/home/lesclownsducarro/public_html/'); 

    public function __construct(Smarty $smarty){
        parent::__construct($smarty);
    }
}


?>
require_once("./php/class/init.php");
$_ENV['class_init'] = new class_init();
$securityPolicy = new Smarty_Security($_ENV['class_init']);
$securityPolicy->php_handling = \Smarty::PHP_ALLOW;
$_ENV['class_init']->enableSecurity($securityPolicy);
获取一个完全空白的页面,错误日志只会声明:

[30-Dec-2019 22:22:40 UTC] PHP Fatal error:  Class 'SmartySecurity' not found in /home/xxxxx/public_html/php/class/init.php on line 32
为了向后兼容,我需要使用SmartyBC,因为模板到处都包含PHP文件。是的,我知道,这不是我的网站


有什么想法吗?

DOH。嗯,我似乎太累了

它显然应该是:
$securityPolicy=newsmarty\u Security($\u ENV['class\u init'])

…带下划线。我不知道,我从smarty.net复制/粘贴了这个示例,根本没有注意。“新SmartySecurity”如下所示:


JFC.

我的自行车也有两处疲劳。