我的单例模式设计,使用后期静态绑定
class Database {
private static $instance = null;
private function __construct(){
}
// 这里使用static进行后期静态绑定,继承该类,即可变身为单例
public static function getInstance(){
if(!(static::$instance===null)){
static::$instance = new static;
}
return static::$instance;
}
private function __clone(){
}
//其他成员
}