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.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
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 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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:
155.89 ms | 401 KiB | 182 Q