fork download
  1. <?php
  2.  
  3. // your code goes here
  4.  
  5. class Foo
  6. {
  7. public $bar = 'I am bar';
  8. }
  9.  
  10. $foo = new Foo;
  11. $property = 'bar';
  12. $array = ['one', 'bar', 'three'];
  13.  
  14. echo $foo->$property . "\n";
  15. echo $foo->$array[1];
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
I am bar
I am bar