3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); const DEFAULT_VALUE = null; function foo(bool $arg = DEFAULT_VALUE) { var_dump($arg); } foo(true); foo(false); foo(null);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
bool(true) bool(false) Fatal error: Uncaught TypeError: foo(): Argument #1 ($arg) must be of type bool, null given, called in /in/SN1FB on line 12 and defined in /in/SN1FB:5 Stack trace: #0 /in/SN1FB(12): foo(NULL) #1 {main} thrown in /in/SN1FB on line 5
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
bool(true) bool(false) NULL

preferences:
118.11 ms | 1443 KiB | 4 Q