I saw a code like this in starttutorial.com:
class Database
{
private static $dbName = 'crud_tutorial' ;
private static $dbHost = 'localhost' ;
private static $dbUsername = 'root';
private static $dbUserPassword = 'root';
private static $cont = null;
public function __construct() {
die('Init function is not allowed');
}
}
public static function connect()
{
// One connection through whole application
if ( null == self::$cont )
{
try
{
self::$cont = new PDO( "mysql:host=".self::$dbHost.";"."dbname=".self::$dbName, self::$dbUsername, self::$dbUserPassword);
}
catch(PDOException $e)
{
die($e->getMessage());
}
}
return self::$cont;
}
and somewhere in the middle of the php file that included this class. I saw this line of code.
$pdo = Database::connect();
From what i know, the __construct method is called when an instance of this class is instantiated. My question is, will the code above call the magic method?