3v4l.org

run code in 300+ PHP versions simultaneously
<?php function someFunction(int $someVariable): boolean { if ($someVariable > 10) { return true; } else if ($someVariable < -10) { return false; } return null; } echo someFunction(11); echo someFunction(-11); echo someFunction(0);
Output for 8.3.0 - 8.3.7
Warning: "boolean" will be interpreted as a class name. Did you mean "bool"? Write "\boolean" to suppress this warning in /in/bdQKO on line 3 Fatal error: Uncaught TypeError: someFunction(): Return value must be of type boolean, true returned in /in/bdQKO:5 Stack trace: #0 /in/bdQKO(12): someFunction(11) #1 {main} thrown in /in/bdQKO on line 5
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19
Warning: "boolean" will be interpreted as a class name. Did you mean "bool"? Write "\boolean" to suppress this warning in /in/bdQKO on line 3 Fatal error: Uncaught TypeError: someFunction(): Return value must be of type boolean, bool returned in /in/bdQKO:5 Stack trace: #0 /in/bdQKO(12): someFunction(11) #1 {main} thrown in /in/bdQKO on line 5
Process exited with code 255.
Output for 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Return value of someFunction() must be an instance of boolean, bool returned in /in/bdQKO:5 Stack trace: #0 /in/bdQKO(12): someFunction(11) #1 {main} thrown in /in/bdQKO on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
Fatal error: Uncaught TypeError: Return value of someFunction() must be an instance of boolean, boolean returned in /in/bdQKO:5 Stack trace: #0 /in/bdQKO(12): someFunction(11) #1 {main} thrown in /in/bdQKO on line 5
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Parse error: syntax error, unexpected ':', expecting '{' in /in/bdQKO on line 3
Process exited with code 255.

preferences:
166.36 ms | 402 KiB | 186 Q