3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types = 1); function hello(string $s) : void { echo "$s\n"; } function fourtyTwo() : int { // returning wrong type return "42"; } // calling with wrong type try { hello(1234); } catch (Throwable $t) { echo $t; } fourtyTwo();
Output for 7.1.7
TypeError: Argument 1 passed to hello() must be of the type string, integer given, called in /in/giu8Q on line 15 and defined in /in/giu8Q:4 Stack trace: #0 /in/giu8Q(15): hello(1234) #1 {main} Fatal error: Uncaught TypeError: Return value of fourtyTwo() must be of the type integer, string returned in /in/giu8Q:10 Stack trace: #0 /in/giu8Q(20): fourtyTwo() #1 {main} thrown in /in/giu8Q on line 10
Process exited with code 255.