3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class foo { public $newfunc; public function __construct() { $this->newfunc = create_function('$a,$b','print "ln($a) + ln($b) = ".log($a * $b);'); call_user_func(array("newfunc",$this->newfunc), 1, 2); $this->$newfunc(1, 2); } } $f = new foo();
based on Nek6D
Output for 7.2.0
Deprecated: Function create_function() is deprecated in /in/MppQB on line 8 Warning: call_user_func() expects parameter 1 to be a valid callback, class 'newfunc' not found in /in/MppQB on line 9 Notice: Undefined variable: newfunc in /in/MppQB on line 10 Fatal error: Uncaught Error: Method name must be a string in /in/MppQB:10 Stack trace: #0 /in/MppQB(15): foo->__construct() #1 {main} thrown in /in/MppQB on line 10
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'newfunc' not found in /in/MppQB on line 9 Notice: Undefined variable: newfunc in /in/MppQB on line 10 Fatal error: Uncaught Error: Method name must be a string in /in/MppQB:10 Stack trace: #0 /in/MppQB(15): foo->__construct() #1 {main} thrown in /in/MppQB on line 10
Process exited with code 255.
Output for 5.3.21 - 5.6.28
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'newfunc' not found in /in/MppQB on line 9 Notice: Undefined variable: newfunc in /in/MppQB on line 10 Fatal error: Method name must be a string in /in/MppQB on line 10
Process exited with code 255.