3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test() { var_dump($this); } $closure = (new \ReflectionFunction('test'))->getClosure(); $object = new \Exception('oops'); $closure = $closure->bindTo($object, get_class($object)); $closure();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Warning: Cannot bind closure to scope of internal class Exception in /in/HF1Lq on line 8 Fatal error: Uncaught Error: Value of type null is not callable in /in/HF1Lq:9 Stack trace: #0 {main} thrown in /in/HF1Lq on line 9
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Cannot bind closure to scope of internal class Exception in /in/HF1Lq on line 8 Fatal error: Uncaught Error: Function name must be a string in /in/HF1Lq:9 Stack trace: #0 {main} thrown in /in/HF1Lq on line 9
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
object(Exception)#1 (7) { ["message":protected]=> string(4) "oops" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/HF1Lq" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(0) { } ["previous":"Exception":private]=> NULL }

preferences:
233.42 ms | 403 KiB | 368 Q