3v4l.org

run code in 300+ PHP versions simultaneously
<?php function testOptional(string $hello, string|null $world = null) { return $hello . ' ' . ($world ?? 'world'); } function testNullable(string $hello, string|null $world) { return $hello . ' ' . ($world ?? 'world'); } echo testOptional('hello'), PHP_EOL; echo testNullable('hello'), PHP_EOL;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
hello world Fatal error: Uncaught ArgumentCountError: Too few arguments to function testNullable(), 1 passed in /in/gXLDH on line 14 and exactly 2 expected in /in/gXLDH:8 Stack trace: #0 /in/gXLDH(14): testNullable('hello') #1 {main} thrown in /in/gXLDH on line 8
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /in/gXLDH on line 3
Process exited with code 255.

preferences:
97.45 ms | 407 KiB | 5 Q