对单例对象的1点疑惑

WBOY
Release: 2016-06-13 12:33:45
Original
833 people have browsed it

对单例对象的一点疑惑

<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 />
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!