日期:2014-05-17  浏览次数:20575 次

请大家帮我看下这是什么错误
类的自动加载别的类都可以自动加载就是tpl类不能自动加载
Fatal error: Class 'Tpl' not found in D:\AppServ\www\yshop\configs\run.inc.php on line 22

我手动 require ROOT_PATH.'/public/Tpl.class.php';又出现这个错误
Fatal error: Access level to Tpl::__construct() must be public (as in class Smarty) in D:\AppServ\www\yshop\public\Tpl.class.php on line 46

<?php 
class Tpl extends Smarty{

static private $instance;

static public function getInstance(){
if(!(self::$instance instanceof self)){
  self::$instance = new self();
}
return self::$instance;
}
private function __clone(){

}

private function __construct(){
$this->setConfigs();
}
private function setConfigs(){
//模板目录
$this->template_dir = ROOT_PATH.'/view/';
//编译目录
$this->compile_dir = ROOT_PATH.'/compile/';
//配置变量目录
$this->config_dir = ROOT_PATH.'/configs/';
//缓存目录
$this->cache_dir = ROOT_PATH.'/cache/';
//是否开启缓存,网站开发调试阶段,我们应该关闭缓存
$this->caching = 0;
//缓存的声明周期
$this->cache_lifetime = 60*60*24;
//左定界符
$this->left_delimiter = '{';
//右定界符
$this->right_delimiter = '}';
}
} 这里是46行

?>

------解决方案--------------------
那就是因为你的Smarty类的构造函数(__construct)访问权限是public,根据oo规则,子类复写的同一方法,访问权限必须低于父类的,所谓的高低关系为(private > protected > public)