<code>static private $_instance = NULL; </code>
When the instance of the class does not exist, this method will create an instance of the class and return this instance. Normally, the name of this method is getInstance
<code>public function getInstance() { if (self::$_instance == NULL) { self::$_instance = new SingleTon(); } return self::$_instance; } </code>
If the user tries to use new or _clone to create a new object of a class, it will break the restrictions of the singleton mode. Therefore, it is also necessary to declare these two methods as private.
<code>private function __construct(){ } private function __clone(){ } </code>
Copyright statement: This article is an original article by the blogger and may not be reproduced without the permission of the blogger.
The above has introduced the php-single pattern, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.