php的单例模式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Factory
{
private static $instance = null;

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

//声明为私有,防止被拷贝
private function __clone(){}

}
Share
Posted in Uncategorized at February 28th, 2010. No Comments.