Exception or error:
i’m learning about telegram bots from a tutorial and the tutorial uses mysqli for connecting to database.
but some parts of code are confusing me and i cannot understand them
in index.php file :
$db = Db::getInstance();
$jok = $db->query("SELECT * FROM jok ORDER BY RAND() LIMIT 1");
we call getInstance() function and store its value in $db.but in db.php file we see that $db is private property
db.php :
class Db {
private $connection;
private static $db;
public static function getInstance($option = null){
if (self::$db == null){
self::$db = new Db($option);
}
return self::$db;
}
also i cannot understand this part of code too :
public static function getInstance($option = null){
if (self::$db == null){
self::$db = new Db($option);
}
How to solve: