class DB {
public static $mysqli;
private $connect = true;
function __construct() {
if ($this->connect) {
$mysqli = new mysqli($this->host, $this->user, $this->password, $this->db);
$mysqli->set_charset("utf8");
$this->mysqli = $mysqli;
$this->connect = false;
}
}
<?php
class DB {
public static $mysqli;
private $connect = true;
private $_instance = null;
private function __construct() {
if ($this->connect) {
$mysqli = new mysqli($this->host, $this->user, $this->password, $this->db);
$mysqli->set_charset("utf8");
$this->mysqli = $mysqli;
$this->connect = false;
}
}
private function __clone(){}
public static function init(){
if($_instance === null){
self::$_instance = new self();
}
return self::$instance;
}
}