3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Return type declaration, // how does it work with nullable declaration // and void / null / nothing returned ... function return_null_or_void_1(): ?string { return null; } function return_null_or_void_2(): ?string { return; } function return_null_or_void_3(): ?string { // return; } var_dump(return_null_or_void_1()).'<br>'; var_dump(return_null_or_void_2()).'<br>'; var_dump(return_null_or_void_3()).'<br>';
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12, 7.4.0 - 7.4.6, 8.0.16, 8.1.9
Fatal error: A function with return type must return a value (did you mean "return null;" instead of "return;"?) in /in/5NTvg on line 12
Process exited with code 255.
Output for 7.0.0 - 7.0.33
Parse error: syntax error, unexpected '?' in /in/5NTvg on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Parse error: syntax error, unexpected ':', expecting '{' in /in/5NTvg on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected ':', expecting '{' in /in/5NTvg on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/5NTvg on line 7
Process exited with code 255.

preferences:
322.98 ms | 1395 KiB | 327 Q