RE: [PHP] Singleton Was: [PHP] OO parent/child relationship
| From: | Andy Crain | Date: | Tue, 07 Oct 2003 17:52:20 +0000 |
| Subject: | RE: [PHP] Singleton Was: [PHP] OO parent/child relationship | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165340@lists.php.net to get a copy of this message | ||
One quick thought:
You might want to add the following to your if statement:
else {
$this->_cache[$key] = new $key;
return $this->_cache[$key];
}
Andy
> -----Original Message-----
> From: Gerard Samuel [mailto:gsam@trini0.org]
> Sent: Monday, October 06, 2003 5:36 PM
> To: 'PHP List'
> Subject: [PHP] Singleton Was: [PHP] OO parent/child relationship
>
> Gerard Samuel wrote:
>
> > Andy Crain wrote:
> >
> >> This all seems like a perfect case for the singleton pattern. See
> >>
> >> http://www.phppatterns.com/index.php/article/articleview/6/1/1/ and
> >>
> >> http://www.phppatterns.com/index.php/article/articleview/75/1/1/
> >> Andy
> >>
> > Im currently trying to wrap the brain around the Singleton Registry
> > article.
> > Wish me luck :)
>
> http://www.trini0.org/index.php
> This is based on work seen at
>
> http://www.phppatterns.com/index.php/article/articleview/75/1/1/
> Yes yes, I know. It uses $GLOBALS, (OO Sin). Father forgive me....
> From the article, Im getting lost with the reason/meaning/purpose of
> the instance() method.
> If anyone can clarify it for me, and let me know if my example would
> need something like it.
> So if you care to critique it, feel free, Ill try not to be hurt ;)
> Thanks
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php