PHP design pattern Singleton open

PHP design pattern Singleton

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators

Singleton refers to the class of generative patterns. It is used to create just one instance of the class, and ensures that no second one appears while the program is running. For example, in the MVC scheme, often this pattern is used to generate the main controller.

trait TSingleton
{
    private static $instanse;

    private function __construct()
    {

    }

    public static function getInstance()
    {
        if(self::$instanse === null){
            self::$instanse = new self();
        }
        return self::$instanse;
    }
}
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation