So in php 5.* versions i would set up constructor to be private and then get only instance of it, and that worked well, memory usage was low.
class bsdb extends mysqli {
private $host = '';
private $account = '';
private $password = '';
private $database = '';
private static $instance;
private function __construct(){
try {
parent::__construct($this->host, $this->account, $this->password, $this->database);
parent::set_charset('utf8');
} catch (mysqli_sql_exception $e) {
log(sprintf("Connect failed: %s\n", mysqli_connect_error()), 'sql');
die('DB Connection error');
}
}
static function instance() {
if (!self::$instance)
self::$instance = new bsdb;
return self::$instance;
}
}
But in php7 im no longer able to do that because version 7 of php doesnt allow me to make constructor private if im inheriting from class that has public constructor. It is throwing me an error.
So my question is what is the best way to do this in new version of php?