3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rechne(?string $test): ?int { return $test; } var_dump(rechne(null)); var_dump(rechne("str"));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.16, 8.4.1 - 8.4.3
NULL Fatal error: Uncaught TypeError: rechne(): Return value must be of type ?int, string returned in /in/1o9rj:4 Stack trace: #0 /in/1o9rj(8): rechne('str') #1 {main} thrown in /in/1o9rj on line 4
Process exited with code 255.
Output for 7.3.16 - 7.3.33, 7.4.3 - 7.4.33
NULL Fatal error: Uncaught TypeError: Return value of rechne() must be of the type int or null, string returned in /in/1o9rj:4 Stack trace: #0 /in/1o9rj(8): rechne('str') #1 {main} thrown in /in/1o9rj on line 4
Process exited with code 255.
Output for 7.1.0, 7.2.29 - 7.2.33
NULL Fatal error: Uncaught TypeError: Return value of rechne() must be of the type integer or null, string returned in /in/1o9rj:4 Stack trace: #0 /in/1o9rj(8): rechne('str') #1 {main} thrown in /in/1o9rj on line 4
Process exited with code 255.
Output for 5.6.0 - 5.6.28, 7.0.0 - 7.0.13
Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /in/1o9rj on line 3
Process exited with code 255.

preferences:
136.46 ms | 410 KiB | 5 Q