3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types=1); function foo(bool $x): string { if ($x) echo 'yes'; echo 'no'; } foo(true); // TypeError
based on sNTiU
Output for 7.0.0 - 7.3.1
yesno Fatal error: Uncaught TypeError: Return value of foo() must be of the type string, none returned in /in/dh8ot:7 Stack trace: #0 /in/dh8ot(9): foo(true) #1 {main} thrown in /in/dh8ot on line 7
Process exited with code 255.
Output for 5.3.22 - 5.6.38
Warning: Unsupported declare 'strict_types' in /in/dh8ot on line 2 Parse error: syntax error, unexpected ':', expecting '{' in /in/dh8ot on line 3
Process exited with code 255.