class A 
{
    private static $_instance = null;
    
    private function __construct(){}
    
    private function __clone(){}
    
    public static function getInstance()
    {
        if(! (self::$_instance instanceof self)){
            self::$_instance = new self();
        }
        return self::$_instance;
    }
}

$obj = A::getInstance();

标签: none

添加新评论