3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function __construct( private Closure $callback ) {} public function show(): void { $this->callback(); } } new A(function() { echo 'Hello world'; })->show();
Output for 8.4.1 - 8.4.3
Fatal error: Uncaught Error: Call to undefined method A::callback() in /in/AKZ5d:9 Stack trace: #0 /in/AKZ5d(15): A->show() #1 {main} thrown in /in/AKZ5d on line 9
Process exited with code 255.
Output for 8.2.0 - 8.2.27, 8.3.0 - 8.3.16
Parse error: syntax error, unexpected token "->" in /in/AKZ5d on line 15
Process exited with code 255.

preferences:
151.28 ms | 954 KiB | 7 Q