<?php class foo { public $bar = 'baz'; } $x = 'bar'; $o = new foo(); echo $o->$x; echo $o->{$x}; echo get_object_vars($o)[$x];
You have javascript disabled. You will not be able to edit any code.