3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); if(PHP_MAJOR_VERSION < 7 or PHP_MINOR_VERSION < 1) die(); function testParam(?string $arg){ var_dump($arg); } testParam(null); testParam("hi"); testParam();
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, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
NULL string(2) "hi" Fatal error: Uncaught ArgumentCountError: Too few arguments to function testParam(), 0 passed in /in/KoUGq on line 13 and exactly 1 expected in /in/KoUGq:7 Stack trace: #0 /in/KoUGq(13): testParam() #1 {main} thrown in /in/KoUGq on line 7
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Output for 7.0.0 - 7.0.20
Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /in/KoUGq on line 7
Process exited with code 255.

preferences:
146.7 ms | 401 KiB | 169 Q