3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo(string $a = null) {} const A = null; function bar(string $a = A) {} foo(); // Deprecated bar(); // Fatal error ?>
Output for 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Deprecated: foo(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in /in/g846c on line 3 Fatal error: Uncaught TypeError: bar(): Argument #1 ($a) must be of type string, null given, called in /in/g846c on line 10 and defined in /in/g846c:7 Stack trace: #0 /in/g846c(10): bar() #1 {main} thrown in /in/g846c on line 7
Process exited with code 255.
Output for 8.1.32 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
Fatal error: Uncaught TypeError: bar(): Argument #1 ($a) must be of type string, null given, called in /in/g846c on line 10 and defined in /in/g846c:7 Stack trace: #0 /in/g846c(10): bar() #1 {main} thrown in /in/g846c on line 7
Process exited with code 255.

preferences:
51.75 ms | 870 KiB | 4 Q