3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function plop(int $val = null) { printf("val = %d\n", $val); } function autre() : int { return null; } plop(42); plop(null); autre();
Output for 7.3.0alpha1 - 7.3.0rc3
val = 42 val = 0 Fatal error: Uncaught TypeError: Return value of autre() must be of the type int, null returned in /in/lkG45:10 Stack trace: #0 /in/lkG45(16): autre() #1 {main} thrown in /in/lkG45 on line 10
Process exited with code 255.
Output for 7.0.0 - 7.2.8
val = 42 val = 0 Fatal error: Uncaught TypeError: Return value of autre() must be of the type integer, null returned in /in/lkG45:10 Stack trace: #0 /in/lkG45(16): autre() #1 {main} thrown in /in/lkG45 on line 10
Process exited with code 255.
Output for 5.5.0 - 5.6.28
Parse error: syntax error, unexpected ':', expecting '{' in /in/lkG45 on line 8
Process exited with code 255.