I have an object that is being thrown into the session array, and I want to run a foreach on the items property.
I can\'t seem to access it. I see that it\'s priva
I see that it's private, but I can't help but wonder why var_dump can show me what the property contains yet I can't read the data as it throws a fatal error?
Please understand you should use getter and setter methods as explained in the chosen answer.
But for completion on why and how it can be read (could help in debugging). Well, the value is there but private methods are surrounded by NULL bytes (ASCII Value 0).
So if you really want to see that value with a var_dump();
$key = "\0_items\0";
var_dump($fun->$key);