The registry also provides nice methods for checking if something has already
been loaded. Thats what I use it for
if (!Zend_Registry::isRegistered('somevar')) {
//do some processing
Zend_Registry::set('somevar', $value);
} else {
$value = Zend_Registry::get('somevar');
}
This helps a lot to store expensive things that could be getting called in
loads of different places.
Jude A.
On Thursday 24 April 2008 05:04:07 am Greg Donald wrote:
> What is gained by using Zend_Registry? Seems to me I could more
> easily use the existing PHP $GLOBALS or even $GLOBALS['registry'] if I
> wanted/needed a namespace.
>
>
> Zend_Registry::set('index', $value);
>
> versus
>
> $GLOBALS['index'] = $value;
>
>
> $value = Zend_Registry::get('index');
>
> versus
>
> $value = $GLOBALS['index'];
>
>
> foreach ($registry as $index => $value) {
> echo "Registry index $index contains:\n";
> var_dump($value);
> }
>
> versus
>
> foreach ($GLOBALS['registry'] as $index => $value) {
> echo "Registry index $index contains:\n";
> var_dump($value);
> }
>
>
> I really don't see the point.