I need to pass a lot of variables to a PHP class from a database and can’t figure out the correct syntax.
This is the class’s variable format:
$this->SetX('X','Y',15);
I have tried these but none work:
$var = 'SetX';
$this->{$var} = array('foo','bar',15);
$this->{$var}('foo','bar',15);
$this->{$var} = "'foo','bar',15";
But none work, can this be done ??
OK, now understand that this is a method, however the method name and it’s associated variables are dynamic and stored in a DB and I therefore need to generate these on the fly.
It’s a method, not an attribute. But the second version would work if you leave out the curly braces: