Home >Backend Development >PHP Tutorial >self:$instance =& $this,该怎么处理

self:$instance =& $this,该怎么处理

WBOY
WBOYOriginal
2016-06-13 10:04:57759browse

self::$instance =& $this
class CI_Base {

private static $instance;

public function CI_Base()
{
self::$instance =& $this;
}

public static function &get_instance()
{
return self::$instance;
}
}

function &get_instance()
{
return CI_Base::get_instance();
}这个类有什么作用

------解决方案--------------------
为了兼容PHP4
------解决方案--------------------
google "单例模式" 
再结合楼上的回复

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