Home >Backend Development >PHP Tutorial >PHP object instantiation singleton method
PHP method of instantiating an object singleton:
Three private and one public: 2 private methods, 1 private property, 1 public method
private function __construct(){} //不可以继承构造方法 private function __clone(){}//不可以继承克隆方法 privare static $_instance;
一公
public static function getinstance(){ if(!isset(static:$_instance)){ static::$_instance=new static(); } return static::$_instance; }
The above is the entire content of this article. I hope that the content of this article can bring some help to everyone's study or work. I also hope to support the PHP Chinese website!
For more articles related to PHP object instantiation singleton methods, please pay attention to the PHP Chinese website!