I want to create a config.php file to keep the various configuration values that usually being changed from project to project, and I want to define a class to keep the config values in this file like the following:
class Config {
const DB_SERVER = 'localhost',
DB_NAME = 'abc',
DB_USERNAME = 'admin',
DB_PASSWORD = '12345',
WEBSITE_NAME = 'My New Website',
IMAGE_DIR = 'img';
}
and so on, I want to define all values as constants inside the class, and I will call them like the following:
$connection = mysql_connect(Config::DB_SERVER, Config::DB_USERNAME, Config::DB_PASSWORD) or die("Database connection failed..");
I want to know: Is this way of setting the project configuration is right? Does this way have any cons? And if it was wrong, then what the best way to do this?