3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { private $name; public function __construct(string $name) { $this->name = $name; } public function __toString() { return $this->name; } } function f(string $a, C $b) : void { var_dump($a, $b); } $a = new C('a'); $b = new C('b'); f($a, $b);
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
string(1) "a" object(C)#2 (1) { ["name":"C":private]=> string(1) "b" }
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 string(1) "a" object(C)#2 (1) { ["name":"C":private]=> string(1) "b" }
Output for 7.0.0 - 7.0.20
string(1) "a" object(C)#2 (1) { ["name":"C":private]=> string(1) "b" } Fatal error: Uncaught TypeError: Return value of f() must be an instance of void, none returned in /in/TbjSo:18 Stack trace: #0 /in/TbjSo(23): f('a', Object(C)) #1 {main} thrown in /in/TbjSo on line 18
Process exited with code 255.

preferences:
167.98 ms | 401 KiB | 173 Q