3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class TestClass { public function baz() { echo "Worked!"; } } $foo = 'bam'; $bam = ['bar' => new TestClass()]; $$foo['bar']->baz(); // function getResult() { // return "string"; // } //echo getResult(){0};
based on eW7s7
Output for 7.0.0 - 7.2.0
Worked!
Output for 5.6.8 - 5.6.28
Warning: Illegal string offset 'bar' in /in/7HYnX on line 12 Notice: Undefined variable: b in /in/7HYnX on line 12 Fatal error: Call to a member function baz() on null in /in/7HYnX on line 12
Process exited with code 255.
Output for 5.4.11 - 5.5.35
Warning: Illegal string offset 'bar' in /in/7HYnX on line 12 Notice: Undefined variable: b in /in/7HYnX on line 12 Fatal error: Call to a member function baz() on a non-object in /in/7HYnX on line 12
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/7HYnX on line 9
Process exited with code 255.