Basically I want to access a variable of a class, but I change the name of the wanted variable dynamically. I’m having a bit problems to explain exactly, but see my code, maybe it gets more clear:
$requirement = array('req1','req2');
foreach($requirements as $requirement)
{
// CHECK FOR REQUIRED PARAMETERS
if(!isset($this->$requirement)) { echo 'foo'; }
}
So I actually want to access $this->req1 and so on, but how do I access it with my iterator-variable? I’m not sure whether this is right already, having difficulties to find out.
Also: How would I access a parents` variable in the same situation ?
$$ (or use magic getters/setters)
or