3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar = __CLASS__; } class Bar extends Foo { private $bar = __CLASS__; } var_dump(Closure::bind(Closure::fromCallable('get_object_vars'), null, Foo::class)(new Bar)); var_dump(Closure::bind(Closure::fromCallable('get_object_vars'), null, Bar::class)(new Bar));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Warning: Cannot rebind scope of closure created from function in /in/FG7Zb on line 13 Fatal error: Uncaught Error: Value of type null is not callable in /in/FG7Zb:13 Stack trace: #0 {main} thrown in /in/FG7Zb on line 13
Process exited with code 255.
Output for 7.4.14 - 7.4.33
Warning: Cannot rebind scope of closure created from function in /in/FG7Zb on line 13 Fatal error: Uncaught Error: Function name must be a string in /in/FG7Zb:13 Stack trace: #0 {main} thrown in /in/FG7Zb on line 13
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.13
Warning: Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() in /in/FG7Zb on line 13 Fatal error: Uncaught Error: Function name must be a string in /in/FG7Zb:13 Stack trace: #0 {main} thrown in /in/FG7Zb on line 13
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Fatal error: Uncaught Error: Call to undefined method Closure::fromCallable() in /in/FG7Zb:13 Stack trace: #0 {main} thrown in /in/FG7Zb on line 13
Process exited with code 255.
Output for 5.6.0 - 5.6.26
Parse error: syntax error, unexpected '(' in /in/FG7Zb on line 13
Process exited with code 255.

preferences:
121.97 ms | 401 KiB | 205 Q