3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public function bar() { return 'Hello'; } } $fooClassName = 'Foo'; $fooInstance = new $fooClassName; $methodName = 'bar'; var_dump($fooInstance->{$bar}());
based on HqDiu
Output for 7.0.0 - 7.2.0
Notice: Undefined variable: bar in /in/In8fN on line 12 Fatal error: Uncaught Error: Method name must be a string in /in/In8fN:12 Stack trace: #0 {main} thrown in /in/In8fN on line 12
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Notice: Undefined variable: bar in /in/In8fN on line 12 Fatal error: Method name must be a string in /in/In8fN on line 12
Process exited with code 255.