3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function __construct(string $optional = null, string $mandatory) {} } new Foo(mandatory: 'bar');
Output for 8.1.2 - 8.1.28, 8.2.10 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught ArgumentCountError: Foo::__construct(): Argument #1 ($optional) not passed in /in/Y7N4G:4 Stack trace: #0 /in/Y7N4G(7): Foo->__construct(NULL, 'bar') #1 {main} thrown in /in/Y7N4G on line 4
Process exited with code 255.

preferences:
72.33 ms | 402 KiB | 30 Q