class DB
{
/**
* @var DB
*/
static $_instance;
/**
* @var false|\mysqli
*/
protected $connection;
/**
* DB constructor.
*/
public function __construct()
{
$database = "DB";
$host = "host";
$user = "user";
$pass = "pass";
$this->connection = mysqli_connect($host, $user, $pass, $database);
}
/**
* @return DB
*/
static function Instance()
{
if (!self::$_instance instanceof DB) self::$_instance = new self();
return self::$_instance;
}
/**
* @return false|\mysqli
*/
public function Conn(){
return $this->connection;
}
}
//Using
$connection = DB::Instance()->Conn()