This article mainly introduces the method of instantiating an object Singleton in PHP, which has good reference value. let's take a look at the method of instantiating an object Singleton in PHP below:
Three private and one public: two private methods, one private property, and one public method
Private function _ construct () {}// the constructor private function _ clone () {}// the clone method privare static $ _ instance cannot be inherited;
Yi gong
Public static function getinstance () {if (! Isset (static: $ _ instance) {static: $ _ instance = new static ();} return static: $ _ instance ;}
The above is all the content of this article. I hope this article will help you in your study or work, and I also hope to support PHP!
For more articles about the single-case method of PHP object instantiation, refer to PHP Chinese network!