PHP对象实例化
class test {
protected static $_instance = null;
private $path = null;
/**
* 实例化
*/
public static function getInstance() {
if( !self::$_instance instanceof self ) {
self::$_instance = new self;
}
return self::$_instance;
}
protected function __construct() {
$this->path = '/app/';
}
public function out() {
echo $this->path;
}
// .....
}
test::getInstance()->out();
浙公网安备 33010602011771号