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($v); 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 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.26, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
integer string object:X double X string int
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
integer string object:X double Deprecated: Function ReflectionType::__toString() is deprecated in /in/Ve1B9 on line 21 X Deprecated: Function ReflectionType::__toString() is deprecated in /in/Ve1B9 on line 21 string Deprecated: Function ReflectionType::__toString() is deprecated in /in/Ve1B9 on line 21 int

preferences:
174.6 ms | 402 KiB | 213 Q