Smarty_Compiler.class.php Error


Smarty_Compiler.class.php Error

致命错误:无法在第 35 行的/home/rainingt/public_html/quadhits/libs/Smarty-2.6.26/Smarty_Compiler.class.php 中重新声明类 Smarty_Compiler。什么意思?

/* $Id: Smarty_Compiler.class.php 3163 2009-06-17 14:39:24Z monte.ohrt $ */
    
/**
 * Template compiling class
 * @package Smarty
 */
    
class Smarty_Compiler extends Smarty {          --------------      this is line 35                  
// internal vars
/**#@+
 * @access private
 */
var $_folded_blocks         =   array();    // keeps folded template blocks
var $_current_file          =   null;       // the current template being compiled
var $_current_line_no       =   1;          // line number for error messages
var $_capture_stack         =   array();    // keeps track of nested capture buffers
var $_plugin_info           =   array();    // keeps track of plugins to load
var $_init_smarty_vars      =   false;
var $_permitted_tokens      =   array('true','false','yes','no','on','off','null');
var $_db_qstr_regexp        =   null;        // regexps are setup in the constructor
var $_si_qstr_regexp        =   null;
var $_qstr_regexp           =   null;
var $_func_regexp           =   null;
var $_reg_obj_regexp        =   null;

这意味着您的类已经在其他地方声明,并且您正在尝试再次声明它。请确保不要包含包含此类的两次相同文件。

一个快速的解决方案是将类包装在此 IF 语句中。您应该始终使用它来避免与您遇到的类似问题的任何问题。

<?php
if(class_exists('Smarty_Compiler') === FALSE){
    //  Your class here
    class Smarty_Compiler extends Smarty {
        // ...
    }
}
?>

或取决于您的编程标记样式...

<?php
if(!class_exists('Smarty_Compiler')){
    //  Your class here
    class Smarty_Compiler extends Smarty {
        // ...
    }
}
?>