3v4l.org

run code in 200+ PHP versions simultaneously
<?php declare(strict_types=1); function AddIntAndFloat(int $a, float $b): int { return (string) $a + $b; } try { echo AddIntAndFloat(1.4,'2'); } catch(TypeError $e) { echo $e->getMessage(), PHP_EOL; } try { echo AddIntAndFloat(1,'2'); } catch(TypeError $e) { echo $e->getMessage(), PHP_EOL; } try { echo AddIntAndFloat(1,1); } catch(TypeError $e) { echo $e->getMessage(), PHP_EOL; }
based on 6UU2v
Output for 7.3.0 - 7.4.0alpha2
Argument 1 passed to AddIntAndFloat() must be of the type int, float given, called in /in/q1PAq on line 8 Argument 2 passed to AddIntAndFloat() must be of the type float, string given, called in /in/q1PAq on line 14 Return value of AddIntAndFloat() must be of the type int, float returned
Output for 7.0.0 - 7.2.20
Argument 1 passed to AddIntAndFloat() must be of the type integer, float given, called in /in/q1PAq on line 8 Argument 2 passed to AddIntAndFloat() must be of the type float, string given, called in /in/q1PAq on line 14 Return value of AddIntAndFloat() must be of the type integer, float returned
Output for 5.3.0 - 5.6.40
Warning: Unsupported declare 'strict_types' in /in/q1PAq on line 1 Parse error: syntax error, unexpected ':', expecting '{' in /in/q1PAq on line 3
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected ':', expecting '{' in /in/q1PAq on line 3
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected ':', expecting '{' in /in/q1PAq on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/q1PAq on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting ')' in /in/q1PAq on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/q1PAq on line 3
Process exited with code 255.