3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function foo(int $integer): int { return $integer; } try { var_dump(foo(1)); } catch (TypeError $e) { echo "Exception! "; var_dump($e); } try { var_dump(foo("1")); } catch (TypeError $e) { echo "Exception! "; var_dump($e); } try { var_dump(foo("a")); } catch (TypeError $e) { echo "Exception! "; var_dump($e); } try { var_dump(foo("0x0F")); } catch (TypeError $e) { echo "Exception! "; var_dump($e); } try { var_dump(foo(0x0F)); } catch (TypeError $e) { echo "Exception! "; var_dump($e); }
based on kXoBL
Output for 7.0.0 - 7.2.0
int(1) int(1) Exception! object(TypeError)#1 (7) { ["message":protected]=> string(100) "Argument 1 passed to foo() must be of the type integer, string given, called in /in/H28Ge on line 20" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/H28Ge" ["line":protected]=> int(3) ["trace":"Error":private]=> array(1) { [0]=> array(4) { ["file"]=> string(9) "/in/H28Ge" ["line"]=> int(20) ["function"]=> string(3) "foo" ["args"]=> array(1) { [0]=> string(1) "a" } } } ["previous":"Error":private]=> NULL } Notice: A non well formed numeric value encountered in /in/H28Ge on line 3 int(0) int(15)
Output for 5.5.0 - 5.6.28
Parse error: syntax error, unexpected ':', expecting '{' in /in/H28Ge on line 3
Process exited with code 255.