3v4l.org

run code in 500+ PHP versions simultaneously
<?php function foo(int $bar) { var_dump($bar); } foo(7); foo(7.0); foo(7.1); foo(7.9); foo('7'); try { foo('7even'); } catch(\Error $e) { echo $e->getMessage() . PHP_EOL; } try { foo('seven'); } catch(\Error $e) { echo $e->getMessage(); }
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
int(7) int(7) Deprecated: Implicit conversion from float 7.1 to int loses precision in /in/bIF5F on line 3 int(7) Deprecated: Implicit conversion from float 7.9 to int loses precision in /in/bIF5F on line 3 int(7) int(7) foo(): Argument #1 ($bar) must be of type int, string given, called in /in/bIF5F on line 11 foo(): Argument #1 ($bar) must be of type int, string given, called in /in/bIF5F on line 16
Output for 8.0.1 - 8.0.30
int(7) int(7) int(7) int(7) int(7) foo(): Argument #1 ($bar) must be of type int, string given, called in /in/bIF5F on line 11 foo(): Argument #1 ($bar) must be of type int, string given, called in /in/bIF5F on line 16
Output for 7.4.0 - 7.4.33
int(7) int(7) int(7) int(7) int(7) Notice: A non well formed numeric value encountered in /in/bIF5F on line 3 int(7) Argument 1 passed to foo() must be of the type int, string given, called in /in/bIF5F on line 16

preferences:
94.17 ms | 1295 KiB | 4 Q