Returns a value stored at offset $index in the registry, or the registry itself.
Example 1.2. registry() / offsetGet() Example
<?php Zend::registry($index=null) // or $registry = Zend::registry(); $value = $registry->offsetGet($index); ?>
If a value has been stored at the $index
offset, that value will be returned. If the
$index
argument is NULL
, the registry itself will be returned (a subclass of
ArrayObject
). This method simply wraps the
offsetGet() method
, with the additional behavior of returned the registry if $index is not given.
To quickly determine if an index is present in the registry, use Zend::isRegistered():
Example 1.3. isRegistered() / offsetExists() Example
<?php Zend::isRegistered($index=null) // or $registry = Zend::registry(); echo $registry->offsetExists($index) ? 'exists' : 'does not exist'; ?>
Iteration requires little effort: