3v4l.org

run code in 300+ PHP versions simultaneously
<?php $blah = false; echo "calling function \n"; try { test($blah); }catch(\Error $e){ echo "Caught\n"; print_r($e); } class Foo { } function test(\Foo $val){ echo "inside test \n"; print_r($val); echo "\n"; } echo "done\n";
Output for 8.3.0 - 8.3.4, 8.3.6
calling function Caught TypeError Object ( [message:protected] => test(): Argument #1 ($val) must be of type Foo, false given, called in /in/ndCY1 on line 8 [string:Error:private] => [code:protected] => 0 [file:protected] => /in/ndCY1 [line:protected] => 18 [trace:Error:private] => Array ( [0] => Array ( [file] => /in/ndCY1 [line] => 8 [function] => test [args] => Array ( [0] => ) ) ) [previous:Error:private] => ) done
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 calling function Caught TypeError Object ( [message:protected] => test(): Argument #1 ($val) must be of type Foo, false given, called in /in/ndCY1 on line 8 [string:Error:private] => [code:protected] => 0 [file:protected] => /in/ndCY1 [line:protected] => 18 [trace:Error:private] => Array ( [0] => Array ( [file] => /in/ndCY1 [line] => 8 [function] => test [args] => Array ( [0] => ) ) ) [previous:Error:private] => ) done
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
calling function Caught TypeError Object ( [message:protected] => test(): Argument #1 ($val) must be of type Foo, bool given, called in /in/ndCY1 on line 8 [string:Error:private] => [code:protected] => 0 [file:protected] => /in/ndCY1 [line:protected] => 18 [trace:Error:private] => Array ( [0] => Array ( [file] => /in/ndCY1 [line] => 8 [function] => test [args] => Array ( [0] => ) ) ) [previous:Error:private] => ) done
Output for 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
calling function Caught TypeError Object ( [message:protected] => Argument 1 passed to test() must be an instance of Foo, bool given, called in /in/ndCY1 on line 8 [string:Error:private] => [code:protected] => 0 [file:protected] => /in/ndCY1 [line:protected] => 18 [trace:Error:private] => Array ( [0] => Array ( [file] => /in/ndCY1 [line] => 8 [function] => test [args] => Array ( [0] => ) ) ) [previous:Error:private] => ) done
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
calling function Caught TypeError Object ( [message:protected] => Argument 1 passed to test() must be an instance of Foo, boolean given, called in /in/ndCY1 on line 8 [string:Error:private] => [code:protected] => 0 [file:protected] => /in/ndCY1 [line:protected] => 18 [trace:Error:private] => Array ( [0] => Array ( [file] => /in/ndCY1 [line] => 8 [function] => test [args] => Array ( [0] => ) ) ) [previous:Error:private] => ) done

preferences:
147.85 ms | 403 KiB | 173 Q