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()]; $output = $$foo; var_dump($$foo); // Correctly reads this var_dump($output['bar']); // $$foo['bar']->baz(); // function getResult() { // return "string"; // } // echo getResult(){0};
based on ZWeQ3
Output for 7.0.0 - 7.2.0
array(1) { ["bar"]=> object(TestClass)#1 (0) { } } object(TestClass)#1 (0) { } Worked!
Output for 5.6.8 - 5.6.28
array(1) { ["bar"]=> object(TestClass)#1 (0) { } } object(TestClass)#1 (0) { } Warning: Illegal string offset 'bar' in /in/SeQnb on line 16 Notice: Undefined variable: b in /in/SeQnb on line 16 Fatal error: Call to a member function baz() on null in /in/SeQnb on line 16
Process exited with code 255.
Output for 5.4.11 - 5.5.35
array(1) { ["bar"]=> object(TestClass)#1 (0) { } } object(TestClass)#1 (0) { } Warning: Illegal string offset 'bar' in /in/SeQnb on line 16 Notice: Undefined variable: b in /in/SeQnb on line 16 Fatal error: Call to a member function baz() on a non-object in /in/SeQnb on line 16
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/SeQnb on line 9
Process exited with code 255.