Home  >  Article  >  Backend Development  >  对单例对象的1点疑惑

对单例对象的1点疑惑

WBOY
WBOYOriginal
2016-06-13 12:33:45833browse

对单例对象的一点疑惑

<br />
static function instance($type = 'op')<br />
    {<br />
        $class = 'blog';<br />
        if (!isset(self::$_instance)) {<br />
            $_tmp = new $class();<br />
            self::$_instance = $_tmp;<br />
            $tmp = null;<br />
        }<br />
        return self::$_instance;<br />
    }<br />

同一个页面不断通过刷新页面请求此单例对象。是否没刷新一次就重新创建一个单例实例?
能否根据传入TYPE不同,而创建不同的实力。 那么  isset(self::$_instance)这里该怎么写

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn