21,887
社区成员
发帖
与我相关
我的任务
分享
<?php
require 'Smarty.class.php';
class Tpl extends Smarty {
private static $instance;
static public function getInstance() {
if (! (self::$instance instanceof self)) {
self::$instance = new self ();
}
return self::$instance;
}
public function __clone() {
}
public function __construct() {
$this->setConfigs ();
}
private function setConfigs() {
define('ROOT_PATH', dirname(__FILE__));
// 模板目录
$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 = '}';
}
}
//$i = Tpl::getInstance();
//var_dump($i);
class Smarty{
public __construct(){}
}
class Tpl extends Smarty{
private __construct(){}//这样肯定报错,报和你主贴同样的错误。因为private > public
}