标签:分享 它的 bsp span color ati 技术分享 csharp img
保证一个类仅有一个实例,并提供一个访问它的全局访问点.
UML:

class A{
private static $instance = null;
private function __contruct(){}
public static getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new static(); //此处注意和new self的区别
}
return self::$instance;
}
}
调用:
$a = A::getInstance();
$a->getInstance();
标签:分享 它的 bsp span color ati 技术分享 csharp img
原文地址:http://www.cnblogs.com/itfenqing/p/7787123.html