php-单例模式

<?php
class sing {
    private static $instence = null;
    private function  __construct() {
    }
    private function __clone() {
    }
    public static function getinstence(){
        if (empty(self::$instence)) {
            self::$instence = new sing();
        }
        return self::$instence;
    }
}

懒汉式

posted @ 2019-12-01 16:02  千载白云  阅读(117)  评论(0编辑  收藏  举报