I’m trying to echo and access the values stored in [“_aVars:private”]
$obj->_vars and $obj->_vars:private doesnt work 🙁
Here’s the var_dump of $obj
object(test_object)#15 (30) {
["sDisplayLayout"]=>
string(8) "template"
["bIsSample"]=>
bool(false)
["iThemeId"]=>
int(0)
["sReservedVarname:protected"]=>
string(6) "test"
["sLeftDelim:protected"]=>
string(1) "{"
["sRightDelim:protected"]=>
string(1) "}"
["_aPlugins:protected"]=>
array(0) {
}
["_aSections:private"]=>
array(0) {
}
["_aVars:private"]=>
array(56) {
["bUseFullSite"]=>
bool(false)
["aFilters"]=>
The
:privatepart of the var_dump output isn’t actually part of the member name, it’s an indicator that the_aVarsmember is private.Because
_aVarsis private, it’s value cannot be accessed from outside of the object, only from inside.You’d need a public getter function or something similar in order to retrieve the value.
Edit
To help clarify this, I made an example:
The above code produces the following output:
Notice how nothing comes after the attempted
var_dump()of the private variable. Since the code doesn’t have access to$obj->yfrom outside, that means thatvar_dump()cannot access it to produce any information about it.Since
$objis a local variable however,var_dump()works fine there. It’s a specific characteristic ofvar_dump()that it will output information about protected and private object member variables, so that’s why you see it in the object dump. It doesn’t mean that you have access to them however.