So I have a config file, config_inc.php:
<?php
static $config = Array();
$config['dbHost'] = 'localhost';
$config['dbPass'] = '';
$config['dbUser'] = 'root';
$config['dbName'] = 'recipes_comments';
?>
And then I have a controller which is supposed to load these variables using require_once:
require_once "config_inc.php";
class Controller {
public function regUser() {
echo $config['dbHost'];
}
}
I tried to find posts with similar errors, but could not find one that provides a solution that fixes this.
When I try to echo a variable defined in config_inc.php as shown above, I get an error that config is undefined.
My question: Why is config not defined in Controller and what's the proper way to do this?