So, Config.php
`class Db extends PDO
{
private $host = 'localhost';
private $dbName = 'core';
private $user = 'root';
private $pass = 'pass';
public function Connect()
{
$dsn = "mysql:host=".$this->host.";dbName=".$this->dbName;
try {
// now we can call the parent PDO constructor:
parent::__construct($dsn, $this->user, $this->pass);
$this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
}
catch (PDOException $e)
{
echo 'Error: '.$e->getMessage();
}
}
}`
Data.php
`require 'Config.php';
$data = new Data($db);
class Data
{
public function __construct(PDO $db)
{
$this->db = $db;
}
public some_data_thing() {
// Can now use $this->db to do any PDO stuff
}
}`
__construct(PDO $db)
doesn't match __contruct($dsn, $this->user, $this->pass)
in Config.php
Notice: Undefined variable: db
Fatal error: Uncaught TypeError: Argument 1 passed to Data::__construct() must be an instance of PDO, null given