3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fn() { throw new Exception('test'); } try { $fn = function() { fn(); }; $fn(); } catch (Exception $e) { foreach ($e->getTrace() as $frame) { $r = new ReflectionFunction($frame['function']); echo($r->isClosure()); } }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Parse error: syntax error, unexpected token "fn", expecting "(" in /in/uL9UC on line 3
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Parse error: syntax error, unexpected 'fn' (T_FN), expecting '(' in /in/uL9UC on line 3
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
Fatal error: Uncaught ReflectionException: Function {closure}() does not exist in /in/uL9UC:12 Stack trace: #0 /in/uL9UC(12): ReflectionFunction->__construct('{closure}') #1 {main} thrown in /in/uL9UC on line 12
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Uncaught exception 'ReflectionException' with message 'Function {closure}() does not exist' in /in/uL9UC:12 Stack trace: #0 /in/uL9UC(12): ReflectionFunction->__construct('{closure}') #1 {main} thrown in /in/uL9UC on line 12
Process exited with code 255.

preferences:
237.01 ms | 402 KiB | 326 Q