3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types=1); function double(int $value) { return 2 * $value; } function coerceInt(string $value) : int { return (int)$value; } $a = double(coerceInt("5")); var_dump($a); $a = double("5"); var_dump($a);
based on 76NoK
Output for 7.0.0 - 7.2.0
int(10) Fatal error: Uncaught TypeError: Argument 1 passed to double() must be of the type integer, string given, called in /in/VhnpM on line 15 and defined in /in/VhnpM:4 Stack trace: #0 /in/VhnpM(15): double('5') #1 {main} thrown in /in/VhnpM on line 4
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/VhnpM on line 2 Parse error: syntax error, unexpected ':', expecting '{' in /in/VhnpM on line 9
Process exited with code 255.