3v4l.org

run code in 500+ PHP versions simultaneously
<?php if (! \function_exists('func_get_named_args')) { /** * Returns the arguments passed to the calling function, keyed by parameter name. * * Uses debug_backtrace and reflection to convert positional arguments * into an associative array keyed by the corresponding parameter names. * * See: https://gist.github.com/ghostwriter/82cffeb51b7052cba489f73a5350adf2 * * @return array<string, mixed> */ function func_get_named_args(): array { $caller = debug_backtrace(0, 2)[1]; $arguments = $caller['args'] ?? []; $reflectionMethod = isset($caller['class']) ? new ReflectionMethod($caller['class'], $caller['function']) : new ReflectionFunction($caller['function']); foreach ($reflectionMethod->getParameters() as $parameter) { $position = $parameter->getPosition(); if (isset($arguments[$position])) { $arguments[$parameter->getName()] = $arguments[$position]; unset($arguments[$position]); } } return $arguments; } } function callFunc(...$params) { $argv = func_get_named_args(); $argc = count($argv); print_r([ '$argc' => $argc, '$argv' => $argv, ]); } class User { public function register($email, $password, $active = null, $default = 0, ...$attributes) { $argv = func_get_named_args(); $argc = count($argv); print_r([ '$argc' => $argc, '$argv' => $argv, ]); return [$email, $password, $attributes]; } } $foo = new User(); $foo->register('admin@test.com', 'pass1', ...[ 'id' => 'uuid-1', 'phone' => '012-345-6789', 'role' => 'admin', ]); echo PHP_EOL . '--------' . PHP_EOL; callFunc(...[ 'id' => 'uuid-2', 'email' => 'test@test.com', 'phone' => '987-654-3210', 'name' => 'first last2', 'role' => 'tester', 'password' => 'pass2' ]);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.100.0070.00416.92
8.5.90.0090.00716.87
8.5.80.0080.00616.76
8.5.70.0080.00516.87
8.5.60.0090.00416.74
8.5.50.0070.00516.75
8.5.40.0050.00516.76
8.5.30.0080.00416.73
8.5.20.0070.00416.77
8.5.10.0080.00516.76
8.5.00.0080.00416.62
8.4.250.0120.00719.71
8.4.240.0100.00519.74
8.4.230.0130.00719.76
8.4.220.0080.00619.61
8.4.210.0100.00719.69
8.4.200.0100.00619.62
8.4.190.0070.00519.67
8.4.180.0070.00919.79
8.4.170.0120.00919.78
8.4.160.0100.00719.74
8.4.150.0120.00619.82
8.4.140.0100.00617.77
8.4.130.0070.00517.78
8.4.120.0070.00517.93
8.4.110.0040.00617.83
8.4.100.0070.00617.90
8.4.90.0050.00417.90
8.4.80.0040.00417.89
8.4.70.0080.00417.93
8.4.60.0120.00517.94
8.4.50.0040.00617.79
8.4.40.0080.00617.87
8.4.30.0070.00217.74
8.4.20.0050.00417.80
8.4.10.0080.00717.76
8.3.330.0100.00518.57
8.3.320.0080.00818.59
8.3.310.0060.00618.57
8.3.300.0120.00418.42
8.3.290.0080.00818.48
8.3.280.0090.00518.47
8.3.270.0090.00416.68
8.3.260.0070.00616.73
8.3.250.0040.00516.76
8.3.240.0060.00417.66
8.3.230.0070.00317.67
8.3.220.0050.00517.63
8.3.210.0070.00317.65
8.3.200.0070.00517.60
8.3.190.0060.00416.72
8.3.180.0060.00516.78
8.3.170.0070.00316.69
8.3.160.0110.00516.86
8.3.150.0080.00416.90
8.3.140.0070.00616.79
8.3.130.0060.00416.91
8.3.120.0080.00616.79
8.3.110.0070.00616.76
8.3.100.0070.00616.75
8.3.90.0060.00716.86
8.3.80.0080.00516.91
8.3.70.0080.00516.80
8.3.60.0100.00416.85
8.3.50.0080.00716.87
8.3.40.0110.00318.09
8.3.30.0090.00518.09
8.3.20.0080.00618.03
8.3.10.0070.00618.03
8.3.00.0130.00618.03
8.2.330.0120.00418.16
8.2.320.0080.00618.02
8.2.310.0100.00818.04

preferences:
54.15 ms | 829 KiB | 5 Q