Here is my code. I do not know why creating new object name site create an error. also the name of the file for my object is the same as the class name site.php.
<?php
class site {
var $is_container_enabled = 1;
function init() {
$this->container_tpl = "common/common";
}
function handle_page($page) {
$this->cache_id = $page;
$this->smarty->caching = 0;
switch ($page) {
case "static" :
$type=$_REQUEST['choice'];
$this->default_tpl = "static/$type";
break;
default :
$this->is_container_enabled = isset($_REQUEST['ce'])?$_REQUEST['ce']:1;
$this->default_tpl = $page.'/home';
break;
}
}
function is_container_enabled(){
return $this->is_container_enabled;
}
function set_container_enabled($ce){
$this->is_container_enabled = $ce;
}
function get_container_tpl(){
return $this->container_tpl;
}
}
some index.php that call the object site
echo "before site declaration";
$site = new site; // cause error
echo "after site declaration";
$site->init();
$smarty = getSmarty();
$site->smarty= &$smarty;
$site->cache_id= &$cache_id;
And here is also Console error image
include 'site.php';
echo "before site declaration";
$site = new site; // You can access member variables/functions with this
echo "after site declaration";
$site->init();
$smarty = getSmarty();
$site->smarty= &$smarty;
$site->cache_id= &$cache_id;
Try this