Astions: I prefer not to use constants, as my array / static object application configuration approach allows me to group certain settings together, such as database settings, email settings etc. in a sub-array. This means I can access them like so (for me organizing variables like this becomes helpful when you are breakpoint debugging and watching variables, especially when the configuration grows larger):
Code: Select all
$x = Config::database->username;
$y Config::database->password;
Arborint: I understand then a class with static member variables is not good practice either, if I understand your post correctly. On the other hand, considering passing the array as a parameter to every single function that needs it seems a waste and not the best and most practical coding practice.
How do I register the array? If what you mention is using register_globals=On or using $GLOBALS or global, I've read many articles warning that it is very insecure and I'd rather not go this direction. I'm having heebie-jeebies on this one. Eek...
I'm actually considering the credibility of using a static object declared as such:
Code: Select all
class Config(){
public static $macintoshIsCool = 'true';
public static $iLoveChocolate = 'sometimes'
}
Then I can simply access it like:
Code: Select all
if(Config::$iLoveChocolate && Config::macintoshIsCool){
// Do something outrageously silly...
}
Maybe one can come up with some solution for loading the Config class, once and once only, creating a checksum (for ex. MD5) across the entire setup, and using member functions (like Config::getILoveChocolate()) which would in turn check against the checksum whether the supposed to be read-only configuration has been altered or tampered with since its initial load.
Just an idea though. Maybe I'm totally

And surely that would cause some performance hit, but at the cost of better security, I think it's worth it. I am VERY paranoid these days.
My previous job apparently had their servers wiped two weeks in a row a few weeks ago due to lack of security, and I don't want this kind of thing to happen to me. They had about 300 websites hosted, and how it happened I don't know. I just know I'm going to take every step to try and keep my sites safe and my clients happy. I am NOT going to be victimized.