3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Try it out */ $user = (new Api)->user(1); echo "Got user ".$user->id; function phpdoc_params(ReflectionMethod $method) : array { // Retrieve the full PhpDoc comment block $doc = $method->getDocComment(); // Trim each line from space and star chars $lines = array_map(function($line){ return trim($line, " *"); }, explode("\n", $doc)); // Retain lines that start with an @ $lines = array_filter($lines, function($line){ return strpos($line, "@") === 0; }); $args = []; // Push each value in the corresponding @param array foreach($lines as $line){ list($param, $value) = explode(' ', $line, 2); $args[$param][] = $value; } return $args; } class Api { /** * @param int $id * @return User * @throws ReflectionException * @endpoint users */ public function user(int $id) : User { return $this->request($this->endpoint(__METHOD__), $id); } /** * @param string $method * @return string * @throws ReflectionException */ protected function endpoint(string $method) : string { $reflection = new \ReflectionMethod($method); $params = phpdoc_params($reflection); return $params['@endpoint'][0] ?? null; } /** * @param string $endpoint * @param $param * @return User */ protected function request(string $endpoint, $param) { switch($endpoint){ case 'users': return new User($param); default: throw new InvalidArgumentException("Invalid endpoint"); } } } /** * Class User */ class User { public $id; public function __construct($id) { $this->id = $id; } }

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.3.60.0130.00618.30
8.3.50.0120.00517.35
8.3.40.0090.00619.02
8.3.30.0100.00718.75
8.3.20.0040.00421.90
8.3.10.0080.00021.73
8.3.00.0080.00021.75
8.2.180.0130.00925.92
8.2.170.0030.01019.14
8.2.160.0030.01020.52
8.2.150.0070.00024.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0000.00720.74
8.2.110.0050.00521.01
8.2.100.0000.01217.72
8.2.90.0060.00318.34
8.2.80.0090.00018.03
8.2.70.0080.00017.93
8.2.60.0080.00017.93
8.2.50.0000.00818.07
8.2.40.0080.00018.28
8.2.30.0030.00617.84
8.2.20.0060.00218.43
8.2.10.0070.00618.28
8.2.00.0090.00417.87
8.1.280.0130.00725.92
8.1.270.0040.00423.99
8.1.260.0150.00426.35
8.1.250.0040.00428.09
8.1.240.0050.00522.80
8.1.230.0070.00420.86
8.1.220.0080.00017.74
8.1.210.0000.00818.97
8.1.200.0030.00517.48
8.1.190.0040.00417.23
8.1.180.0060.00318.10
8.1.170.0000.00818.50
8.1.160.0040.00717.90
8.1.150.0070.00617.94
8.1.140.0070.00617.88
8.1.130.0090.00317.45
8.1.120.0080.00517.51
8.1.110.0080.00517.50
8.1.100.0100.00317.52
8.1.90.0100.00417.49
8.1.80.0090.00317.48
8.1.70.0070.00617.45
8.1.60.0120.00417.63
8.1.50.0110.00517.56
8.1.40.0110.00617.58
8.1.30.0110.00617.61
8.1.20.0090.00517.62
8.1.10.0100.00417.54
8.1.00.0110.00517.50
8.0.300.0070.00019.98
8.0.290.0000.00716.88
8.0.280.0100.00317.44
8.0.270.0050.00816.87
8.0.260.0050.00716.84
8.0.250.0070.00516.88
8.0.240.0070.00217.43
8.0.230.0090.00217.52
8.0.220.0060.00416.95
8.0.210.0080.00116.88
8.0.200.0090.00316.92
8.0.190.0070.00616.91
8.0.180.0080.00416.97
8.0.170.0110.00216.97
8.0.160.0080.00616.92
8.0.150.0070.00616.83
8.0.140.0060.00616.88
8.0.130.0080.00315.97
8.0.120.0080.00516.92
8.0.110.0070.00716.94
8.0.100.0080.00516.92
8.0.90.0090.00316.92
8.0.80.0080.00716.84
8.0.70.0070.00416.88
8.0.60.0060.00716.93
8.0.50.0090.00416.93
8.0.30.0080.00916.88
8.0.20.0100.00816.95
8.0.10.0140.00617.02
8.0.00.0120.00516.93
7.4.330.0080.00216.74
7.4.320.0110.00316.68
7.4.300.0100.00316.64
7.4.290.0130.00216.68
7.4.280.0100.00616.67
7.4.270.0090.00616.66
7.4.260.0120.00316.69
7.4.250.0120.00416.68
7.4.240.0090.00516.69
7.4.230.0090.00416.67
7.4.220.0060.00616.68
7.4.210.0080.00616.61
7.4.200.0070.00616.63
7.4.190.0120.00416.72
7.4.180.0100.00616.68
7.4.160.0120.00516.57
7.4.150.0160.00516.62
7.4.140.0140.00416.60
7.4.130.0120.00816.63
7.4.120.0140.00616.59
7.4.110.0120.00716.60
7.4.100.0130.00716.60
7.4.90.0110.00816.57
7.4.80.0130.00617.02
7.4.70.0130.00416.53
7.4.60.0100.00716.59
7.4.50.0120.00716.55
7.4.40.0130.00416.60
7.4.30.0120.00616.62
7.4.20.0120.00516.57
7.4.10.0120.00416.61
7.4.00.0080.01016.55
7.3.330.0100.00415.77
7.3.320.0130.00115.74
7.3.310.0080.00616.53
7.3.300.0090.00616.55
7.3.290.0080.00716.58
7.3.280.0120.00616.49
7.3.270.0160.00516.59
7.3.260.0120.00616.52
7.3.250.0120.00916.59
7.3.240.0120.00716.50
7.3.230.0130.00616.57
7.3.220.0120.00916.49
7.3.210.0140.00616.54
7.3.200.0090.00816.59
7.3.190.0140.00316.58
7.3.180.0100.00716.60
7.3.170.0100.00716.51
7.3.160.0100.00616.52
7.3.150.0110.00616.57
7.3.140.0130.00516.50
7.3.130.0110.00816.51
7.3.120.0120.00516.50
7.3.110.0110.00716.51
7.3.100.0130.00616.58
7.3.90.0120.00616.63
7.3.80.0120.00516.52
7.3.70.0110.00616.47
7.3.60.0090.00716.52
7.3.50.0100.00716.50
7.3.40.0090.00816.08
7.3.30.0080.00716.24
7.3.20.0090.00816.97
7.3.10.0070.01016.97
7.3.00.0110.00916.93
7.2.340.0120.00716.69
7.2.330.0140.00516.57
7.2.320.0120.00916.69
7.2.310.0120.00816.68
7.2.300.0100.00816.56
7.2.290.0120.00816.57
7.2.280.0140.00516.62
7.2.270.0150.00616.70
7.2.260.0160.00516.70
7.2.250.0110.00916.60
7.2.240.0110.01016.60
7.2.230.0090.01116.69
7.2.220.0130.00616.70
7.2.210.0140.00516.59
7.2.200.0120.00816.63
7.2.190.0130.00616.59
7.2.180.0130.00616.60
7.2.170.0140.00716.45
7.2.160.0130.00616.38
7.2.150.0120.00817.21
7.2.140.0120.00617.17
7.2.130.0160.00817.24
7.2.120.0140.00817.24
7.2.110.0140.00717.20
7.2.100.0140.00617.17
7.2.90.0160.00717.22
7.2.80.0110.00917.21
7.2.70.0140.00517.27
7.2.60.0150.00517.20
7.2.50.0090.00817.21
7.2.40.0140.00717.28
7.2.30.0120.00917.25
7.2.20.0130.00617.20
7.2.10.0120.00617.18
7.2.00.0130.00617.21
7.1.330.0110.01016.61
7.1.320.0130.00916.73
7.1.310.0120.00616.64
7.1.300.0140.00716.64
7.1.290.0130.00816.70
7.1.280.0150.00716.27
7.1.270.0150.00516.29
7.1.260.0180.00916.30
7.1.250.0280.00716.22
7.1.240.0190.00716.64
7.1.230.0130.00816.66
7.1.220.0130.00716.64
7.1.210.0150.00816.63
7.1.200.0160.00416.65
7.1.190.0140.00616.57
7.1.180.0190.00716.65
7.1.170.0140.00716.65
7.1.160.0140.00716.67
7.1.150.0150.00816.63
7.1.140.0150.00616.59
7.1.130.0160.00716.63
7.1.120.0160.00416.63
7.1.110.0130.00616.69
7.1.100.0100.00916.64
7.1.90.0130.00716.68
7.1.80.0140.00716.63
7.1.70.0170.00416.62
7.1.60.0140.00816.64
7.1.50.0150.00616.68
7.1.40.0160.00516.62
7.1.30.0140.00716.63
7.1.20.0130.00716.70
7.1.10.0140.00716.69
7.1.00.0130.00616.69

preferences:
53.69 ms | 401 KiB | 5 Q