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