php - Getting the property value from an array contained in an object that itself is contained in another object -
i trying property of array contained within object contained in object.
the code below var_dump
ed object . trying value property identity i.e 'identity' => int 101 ..
i put 'identity' => 101 in asterisk demonstration purposes only; rendered values not have asterisk. 4th last line of code.
i know how values multidimensional arrays; not sure multidimensional objects
object(zfcuser\authentication\adapter\adapterchain)[373] protected 'event' => object(zfcuser\authentication\adapter\adapterchainevent)[456] protected 'name' => string 'authenticate.success' (length=20) protected 'target' => &object(zfcuser\authentication\adapter\adapterchain)[373] protected 'params' => array (size=4) 'request' => object(zend\http\phpenvironment\request)[194] ... **'identity' => int 101** 'code' => int 1 'messages' => array (size=1)
to access object's property syntax used ->
, in object->property
. access given property, it's visibility has public
opposed example, properties have protected
visibility.
to access identity
need run $object->event->params['identity']
, need define getter function or change properties' visibility public.
an example of getter function
public function __get($name){ return $this->$name; }
or single property
public function getevent(){ return $this->event; }
then syntax used ( assuming define getter function params
)
$object->getevent()->getproperties()['identity'];
Comments
Post a Comment