Well, this is strictly a PHP question, but I know you guys are smart and friendly, so I’m hoping someone can explain this to me.
I’m trying to store some data in a variable location in an object, and that data is various hash keys.
Consider the following code contained in one of my object’s functions:
$storage_loc = 'somewhere';
// $this->$storage_loc[$key] = $value; // don't work
// $this->$storage_loc->$key = $value; // works, but stores as an object
// $this->$storage_loc = array_merge( $this->$storage_loc, array($key => $value) ); // Doesn't work
$this->vars[$key] = $value; // static properties work fine
Why can’t I use a variable to identify an object PROPERTY? I can use a variable to define an object FUNCTION without any problems.
Thanks for any tips.