3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X {} function foo(...$args) { foreach ($args as $v) { $t = gettype($v); if ($t === 'object') { $c = get_class($t); echo "$t:$c\n"; } else { echo "$t\n"; } } $f = function(X $x, string $y, int $z) {}; $ref_func = new ReflectionFunction($f); $ref_params = $ref_func->getParameters(); foreach ($ref_params as $p) { echo "{$p->getType()}\n"; } } foo(42, "hello", new X(), 1.2e3);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
integer string Fatal error: Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, string given in /in/WDJ1O:10 Stack trace: #0 /in/WDJ1O(25): foo(42, 'hello', Object(X), 1200.0) #1 {main} thrown in /in/WDJ1O on line 10
Process exited with code 255.
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 integer string Fatal error: Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, string given in /in/WDJ1O:10 Stack trace: #0 /in/WDJ1O(25): foo(42, 'hello', Object(X), 1200.0) #1 {main} thrown in /in/WDJ1O on line 10
Process exited with code 255.
Output for 8.0.0 - 8.0.30
integer string Fatal error: Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, string given in /in/WDJ1O:10 Stack trace: #0 /in/WDJ1O(25): foo(42, 'hello', Object(X), 1200) #1 {main} thrown in /in/WDJ1O on line 10
Process exited with code 255.
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
integer string Warning: get_class() expects parameter 1 to be object, string given in /in/WDJ1O on line 10 object: double Deprecated: Function ReflectionType::__toString() is deprecated in /in/WDJ1O on line 21 X Deprecated: Function ReflectionType::__toString() is deprecated in /in/WDJ1O on line 21 string Deprecated: Function ReflectionType::__toString() is deprecated in /in/WDJ1O on line 21 int
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.26
integer string Warning: get_class() expects parameter 1 to be object, string given in /in/WDJ1O on line 10 object: double X string int

preferences:
151.59 ms | 402 KiB | 173 Q