Can not declare twice, smarty

Hello, Thanks for all that try to help me. I have a coding issue that I need help with. First, this is a smarty site. My job is to change the naming of some of the smarty files as well as other files, so the paths and all else is set right because the site worked before I started changing them. The site is loaded within a folder under the root folder. On the home page, or Public_html/Software Project/index.php I am getting this error.




Fatal error: Call to undefined method stdClass::display() in /home/russia6/public_html/Software Projects/Apex Framework/index.php on line 12

The index.php coding is



<?php
require_once("includes/config.php");
require_once("includes/connection.php");
require_once("includes/data.php");
require_once("includes/utils.php");
require_once("libs/smarty.php");

                           


$smarty->caching = 1;
$smarty->display("index.tpl");
?>                               sn


line 12 is $smarty->display(“index.tpl”);

The only thing I can think of is that someone modified smarty.php by created a RuSmarty function Below is the smarty.php code


<?php
require_once(dirname(__FILE__) . '/../includes/config.php');
require_once('smarty/Smarty.class.php');


// 12.24.7; wiseobject <- 
define('WZ_SMARTY_BASE',dirname(__FILE__).'/smarty');
define('WZ_SMARTY_TEMPLATE',WZ_BASE.'/templates');
define('WZ_SMARTY_CONFIG',WZ_BASE.'/configs');
define('WZ_SMARTY_COMPILE',WZ_BASE.'/templates_c');

class RuSmarty extends Smarty {
	function RuSmarty() {
		
		$this->Smarty();
		
		//$this->template_dir = TEMPLATES_DIR . 'default/';
		// 12.24.7; wiseobject <-
		$this->compile_dir = WZ_SMARTY_COMPILE; // COMPILE_DIR;
		$this->config_dir = WZ_SMARTY_CONFIG; // CONFIG_DIR;
		$this->cache_dir = WZ_SMARTY_BASE.'/cache/'; //SMARTY_DIR . 'cache/';
		$this->plugins_dir = WZ_SMARTY_BASE.'/plugins/'; //SMARTY_DIR . 'plugins/';
		$this->template_dir = WZ_SMARTY_TEMPLATE; //getcwd().'/templates';//TEMPLATES_DIR;
		
		$this->caching = false;
		$this->debugging = false;
	}
}
?>


Has the $smarty variable been properly instantiated ( i.e.: $smarty = new RuSmarty(); ) somewhere before you try to use it? Based on the error message, I’d say it hasn’t been.

All Fixed. That was what the problem was and Thanks. One more thing, do you know why that would give an undefined method error.

$smarty->caching = 1;
$smarty->display(“index.tpl”);

The first line here, where you set caching to 1, implicitly instantiates a standard object (stdClass), which does not have a method called display.

As such, when you try to call $smarty->display(“index.tpl”), since the method doesn’t exist in stdClass, it throws that error.