Not a bad idea, however in my case (don't know about others) I have very deep arrays i use for my configuration. This would be more of a pain to use with these get and set functions. Also, the performance would probably be worse than just directly accessing the variable.
Good point about not fixing what's not broken, but I think in this context it couldn't hurt to fix it. I have already fixed it, my patch is already written and I will continue testing it but I haven't come across any problems using it. On Sat, 2007-11-17 at 01:05 -0500, Carl P. Corliss wrote: > Sam Barrow wrote: > > Thanks everyone, I knew this, but I didn't want to use runkit because it > > is a beta, and i don't want all that other stuff, just superglobals. > > Also, runkit only allows you to use php.ini, but my patch allows you to > > specify superglobals in your script with the keyword "superglobal" by > > saying: > > > > superglobal $var1, $var2 ; > > I don't get why you can't just use a Registry pattern here. Having a > simpleRegistry object that you can throw data into and pull out of not only > allows you to keep your global space clean, but allows you to encapsulate > your "global" data and access it via a simple interface. Sure, it might be a > few extra keystrokes to type something akin to: Registry::get('var1'); but, > personally, I think the trade-off is well worth it. > > simple example class: > -------------------- > class Registry { > protect function __construct() {} // no instantiation - static class > static protected $data = array(); > > static public function get($name) { > return (isset(self::$data[$name]) ? self::$data[$name] : null); > } > > static public function set($name, value) { > self::$data[$name] = $value; > } > } > -------------------- > > summary: why "fix" what ain't really broke...? > > Cheers!, > > -- > Carl > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php