3v4l.org

run code in 300+ PHP versions simultaneously
<?php class weasel { } function show1(int $value) { var_dump($value); } function show2(weasel $value) { var_dump($value); } try { show1(new weasel()); } catch (throwable $e) { echo $e->getMessage(), "\n"; } try { show2(10); } catch (throwable $e) { echo $e->getMessage(), "\n"; }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
show1(): Argument #1 ($value) must be of type int, weasel given, called in /in/HgpGj on line 15 show2(): Argument #1 ($value) must be of type weasel, int given, called in /in/HgpGj on line 20
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Argument 1 passed to show1() must be of the type int, object given, called in /in/HgpGj on line 15 Argument 1 passed to show2() must be an instance of weasel, int given, called in /in/HgpGj on line 20
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
Argument 1 passed to show1() must be of the type integer, object given, called in /in/HgpGj on line 15 Argument 1 passed to show2() must be an instance of weasel, integer given, called in /in/HgpGj on line 20
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Catchable fatal error: Argument 1 passed to show1() must be an instance of int, instance of weasel given, called in /in/HgpGj on line 15 and defined in /in/HgpGj on line 6
Process exited with code 255.

preferences:
208.09 ms | 402 KiB | 324 Q