3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function __construct( private Closure $callback ) {} public function show(): void { $this->callback->__invoke(); } } new A(function() { echo 'Hello world'; })->show();
Output for 8.4.1 - 8.4.3
Hello world
Output for 8.2.0 - 8.2.27, 8.3.0 - 8.3.16
Parse error: syntax error, unexpected token "->" in /in/iZ0VR on line 15
Process exited with code 255.

preferences:
149.18 ms | 954 KiB | 7 Q