PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Accessing the Registry as an Object

You may also find it convenient to access the registry in an object-oriented fashion by using index names as object properties. You must specifically construct the registry object using the ArrayObject::ARRAY_AS_PROPS option and initialize the static instance to enable this functionality.

Note

You must set the ArrayObject::ARRAY_AS_PROPS option before the static registry has been accessed for the first time.

Known Issues with the ArrayObject::ARRAY_AS_PROPS Option

Some versions of PHP have proven very buggy when using the registry with the ArrayObject::ARRAY_AS_PROPS option.

Example 690. Example of Object Access

<?php
// in your application bootstrap:
$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS)
Zend_Registry::setInstance($registry);
$registry->tree 'apple';

.
.
.

// in a different function, elsewhere in your application:
$registry Zend_Registry::getInstance();

echo 
$registry->tree// echo's "apple"

$registry->index $value;

var_dump($registry->index);

Zend Framework