Good Idea or Bad Idea? Using a Static Class Variable to Store a Global

I have a class that I am using all over the place in my code. It contains settings and other core functionality. Here's what I'm doing right now to use the class.\[code\]$settings = new Settings();$settings->loadSettings();\[/code\]Then, when I need to the code in some random function in another class, I do something like this:\[code\]function abc() { global $settings; $variable = $settings->a;}\[/code\]I'm sick and tired of randomly calling global $settings all over the place to pull in that settings object. I don't want to use the $_GLOBALS array (I don't know why, I just don't want to).I'm thinking I want to switch to have a static class variable called $settings inside of settings. The code would look like this:\[code\]Settings::$settings = new Settings();Settings::$settings->loadSettings();\[/code\]Then, whenever I want to use it, I never have to worry about sucking it in via the global operator:\[code\]function abc() { $variable = Settings::$settings->a;}\[/code\]Good idea or bad idea?
 
Back
Top