聘我网

新概念招聘3.0

解释一段代码,new self()

vote up0vote downstar
public static function getInstance()
{
    if ( ! isset(self::$_instance)) {
        self::$_instance = new self();
    }
    return self::$_instance;
}

new self()是什么意思?

 

1 个答复

vote up0vote downcheck

这段是典型的单一模式(singleton pattern)__construct()private

self表示当前所在的class

链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.