I have a property stored in a string ... say Object Foohas a property Bar, so to get the value of the property BarI would call ..
Console.Write(foo.Bar);
Now tell me what I have "Bar", stored in a string variable ...
string property = "Bar"
Foo foo = new Foo();
how to get the value foo.Barwith property?
How do I use this in PHP
$property = "Bar";
$foo = new Foo();
echo $foo->{$property};
source
share