Hi all...

I'm trying to build a simple configureation class (using the singleton pattern). Using PHP5, I want to use the __get and __set methods to access configuration settings for my site. However, they don't work :P Here's my class definition:

class Configuration {
        static private $ConfigSettings;

        private function __construct() {
                
        }

        public static function __get($Setting) {
                if (!is_array(self::$ConfigSettings)) {
                        require_once(dirname(__FILE__) . 
'/../../configs/Framework.conf.php');
                }

                if (isset(self::$ConfigSettings[$Setting])) {
                        return self::$ConfigSettings[$Setting];
                }

                return NULL;
        }

        public static function __set($Setting, $Value) {
                self::$ConfigSettings[$Setting] = $Value;
        }
}

However, instead of doing something like:

Configuration::DbType = 'mysql';

I have to use:

Configuration::__set('DbType', 'mysql');

It works, yes, but not quite like I want it to - it just seems 'ugly' to me.

This is using PHP5 RC1 on Apache 2.0.49 (linux).

Any suggestions?

Dave

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to