I have a little doubt, I understand that using global variables is a bad practice.
I have a small MVC application with php, in which I would like to create a file .. called config.php and inside it, save the global variables that I will use in my classes, example ...
$config = array ();
$config ['db_host'] = 'localhost';
Now, I would like to know what would be the recommended way to include this file in my application .. I have implemented a autoloader, I could include it in this ...
Class Autoload
{
public function __construct () {
global $ config;
require_once 'config.php';
}
}
But I really do not know if this is a good practice ...
Thank you very much in advance..