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.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.20, 8.3.0 - 8.3.8
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 5.6.0 - 5.6.40
Parse error: syntax error, unexpected ':', expecting '{' in /in/5NTvg on line 7
Process exited with code 255.

preferences:
178.41 ms | 998 KiB | 7 Q