Zend Framework 101: Zend_Registry
Access the Registry Using Array Syntax
Zend_Registry class extends the built-in
ArrayObject class (see http://php.net/arrayobject for more details), it is possible to access the registry (read and write) using array notation.
This is extremely useful when you want to perform multiple registry operations in a single block of code, since it will clean up your code slightly from using the full static methods.
To access the registry using array notation, you must first retrieve the
Zend_Registry instance using the
Listing 4 shows an example of retrieving the
Zend_Registry instance and reading and writing values.
require_once('Zend/Registry.php'); $registry = Zend_Registry::getInstance(); $registry['name'] = 'Quentin Zervaas'; echo sprintf('My name is %s', $registry['name']);
ArrayObjectif you want the ability to access objects using array notation. It can be extremely useful and provide some fairly powerful functionality.