您的位置:首页 > 编程语言 > PHP开发

PHP对象实例化

2011-10-08 09:49 183 查看
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();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: