When I use require_once
and try to access the variable within the required file I get an error that the variable ($db
) is undefined.
I have tried to place the require_once
statement several diffrent places because I thought it might be variable scope issues, but at this point I try to call it within the constructor and the assign the value to a class variable.
My config class:
class Config {
public $db;
public function __construct() {
require_once (BASE_DIR."config/DBConfig.php");
$this->db = $db;
}
}
The DBConfig file looks like this:
$db['default']['hostname'] = 'localhost'