3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // The difference between the $fnc() and call_user_func($fnc) class A { function foo() { echo 'foo'; } } class B extends A { function __call($name, $args) { $fnc = 'parent::foo'; call_user_func($fnc); // works $fnc(); // error Call to undefined function parent::foo() } } $b = new B; $b->bar();
Output for 7.0.0 - 7.2.0
foo Fatal error: Uncaught Error: Class 'parent' not found in /in/iBMM2:20 Stack trace: #0 /in/iBMM2(25): B->__call('bar', Array) #1 {main} thrown in /in/iBMM2 on line 20
Process exited with code 255.
Output for 5.4.0 - 5.6.28
foo Fatal error: Call to undefined function parent::foo() in /in/iBMM2 on line 20
Process exited with code 255.