简单实现单例原理

//单例模式
class MySQL
{
    private static $instance;
 
    private function __construct()
    {
    }
 
    private function __clone()
    {
    }
 
    public static function getInstance()
    {
        if (!self::$instance instanceof self) {
            self::$instance = new self();
        }
        return self::$instance;
    }
}

posted on 2023-08-07 11:25  何苦->  阅读(4)  评论(0编辑  收藏  举报

导航