Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33206 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40297 invoked by uid 1010); 17 Nov 2007 06:05:34 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 40282 invoked from network); 17 Nov 2007 06:05:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2007 06:05:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=php-php-dev@m.gmane.org; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=news@ger.gmane.org; sender-id=pass Received-SPF: pass (pb1.pair.com: domain m.gmane.org designates 80.91.229.2 as permitted sender) X-PHP-List-Original-Sender: php-php-dev@m.gmane.org X-Host-Fingerprint: 80.91.229.2 main.gmane.org Linux 2.5 (sometimes 2.4) (4) Received: from [80.91.229.2] ([80.91.229.2:49723] helo=ciao.gmane.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 14/8D-51194-BA48E374 for ; Sat, 17 Nov 2007 01:05:32 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1ItGo4-0007sW-0i for internals@lists.php.net; Sat, 17 Nov 2007 06:05:28 +0000 Received: from pool-71-184-159-90.bstnma.fios.verizon.net ([71.184.159.90]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 17 Nov 2007 06:05:27 +0000 Received: from rabbitt by pool-71-184-159-90.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 17 Nov 2007 06:05:27 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: internals@lists.php.net Date: Sat, 17 Nov 2007 01:05:17 -0500 Lines: 38 Message-ID: References: <8D.46.01128.768AD374@pb1.pair.com> <1195246391.21084.15.camel@sbarrow-desktop> <1195250285.4012.6.camel@johannes.nop> <1195251014.21084.20.camel@sbarrow-desktop> Reply-To: carl.corliss@xaraya.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-71-184-159-90.bstnma.fios.verizon.net User-Agent: Thunderbird 2.0a1 (Windows/20060724) In-Reply-To: <1195251014.21084.20.camel@sbarrow-desktop> X-Antivirus: avast! (VPS 071116-0, 11/16/2007), Outbound message X-Antivirus-Status: Clean Sender: news Subject: Re: [PHP-DEV] Re: Question about superglobals From: rabbitt@xaraya.com ("Carl P. Corliss") 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