Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
544 B
5
Indexable
Never
<?php


class Mysql{
    //static self
    public static $db;

    public static function getInstance(){
        if(! isset(self::$db))
        {
            self::$db=new self();
        }
        return self::$db;
    }
    private function __construct()
    {
        
    }
    function connect(){
        echo 'you are connect yo db';
    }

}



// Mysql::$db;

// $db1 = new Mysql();
// $db2 = new Mysql();

// $db1->connect();
// $db2->connect();
$db=Mysql::getInstance();
$db->connect();

$db1 = Mysql::getInstance();

$db1->connect();