3v4l.org

run code in 300+ PHP versions simultaneously
<?php $category = function(string $name, $parent = null) { return new class($name, $parent) { public $name; public $parent; public function __construct(string $name, $parent = null) { $this->name = $name; $this->parent = $parent; } public function breadcrumbs(array $trail = [], ?callable $decorator = null) { $decorator = $decorator ?? function(string $item) { return $item; }; $trail[] = $decorator($this->name); return $this->parent ? $this->parent->breadcrumbs($trail, $decorator) : $trail; } }; }; $categorize = function(...$categories) use($category) { return array_reduce(array_reverse($categories), function($set, $item) use($category) { if (!$set) { return $category($item); } return $category($item, $set); }); }; $product = function(string $name, string $sku, ...$categories) use($categorize) { return new class($name, $sku, $categorize(...$categories)) { public $name; public $categories; public $sku; public function __construct(string $name, string $sku, $categories) { $this->name = $name; $this->sku = $sku; $this->categories = $categories; } public function trail(string $separator = ' / ', ?callable $decorator = null): string { return implode($separator, $this->categories->breadcrumbs([], $decorator)); } public function linkSimilar(string $separator = ' / '): string { return $this->trail($separator, function(string $name) { return sprintf('<a href="/category/%s?similar-to=product/%s">%s</a>', $name, $this->sku, $name); }); } }; }; $book = $product('Harry Potter', 'U425261', 'books', 'hardback', 'young-adult'); $shoes = $product('Air Jordans', 'U425262', 'shoes', 'mens', 'sports', 'basketball'); $tapeMeasure = $product('Stanley 25', 'U425263', 'hardware', 'tools', 'measurement'); var_dump( $book->trail(), $shoes->trail(' | '), $tapeMeasure->linkSimilar(PHP_EOL.' > ') );

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.4.120.0120.00824.17
8.4.110.0150.00622.39
8.4.100.0080.00217.82
8.4.90.0130.00617.81
8.4.80.0150.00617.90
8.4.70.0060.00419.40
8.4.60.0120.00918.85
8.4.50.0050.00418.58
8.4.40.0100.01017.88
8.4.30.0140.00718.75
8.4.20.0060.01322.36
8.4.10.0090.00022.30
8.3.250.0090.01118.77
8.3.240.0040.00417.05
8.3.230.0120.00816.81
8.3.220.0140.00617.23
8.3.210.0140.00616.77
8.3.200.0030.00516.68
8.3.190.0110.00717.24
8.3.180.0100.00819.23
8.3.170.0140.00717.30
8.3.160.0140.00016.63
8.3.150.0120.00617.29
8.3.140.0090.00916.50
8.3.130.0000.01118.67
8.3.120.0040.01118.66
8.3.110.0030.00620.94
8.3.100.0040.00424.06
8.3.90.0090.00626.77
8.3.80.0060.00318.40
8.3.70.0040.01116.75
8.3.60.0110.00416.63
8.3.50.0160.00923.70
8.3.40.0090.00619.52
8.3.30.0090.00618.68
8.3.20.0040.00424.18
8.3.10.0080.00024.66
8.3.00.0060.00326.16
8.2.290.0090.00722.71
8.2.280.0110.00818.25
8.2.270.0090.00916.74
8.2.260.0060.00318.62
8.2.250.0150.00316.67
8.2.240.0130.00618.84
8.2.230.0060.00322.58
8.2.220.0030.00637.54
8.2.210.0040.00426.77
8.2.200.0040.00718.42
8.2.190.0040.01116.63
8.2.180.0180.00425.92
8.2.170.0040.01419.09
8.2.160.0100.00322.96
8.2.150.0040.00425.66
8.2.140.0050.00324.66
8.2.130.0070.00026.16
8.2.120.0070.00021.06
8.2.110.0070.00320.47
8.2.100.0040.00817.72
8.2.90.0030.00619.40
8.2.80.0080.00017.97
8.2.70.0060.00317.63
8.2.60.0050.00317.93
8.2.50.0040.00418.07
8.2.40.0000.00819.83
8.2.30.0050.00218.03
8.2.20.0070.00018.15
8.2.10.0040.00419.22
8.2.00.0040.00419.41
8.1.330.0100.00918.40
8.1.320.0140.00616.26
8.1.310.0000.00816.66
8.1.300.0080.00016.09
8.1.290.0060.00330.84
8.1.280.0140.00025.92
8.1.270.0030.00523.99
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0040.00423.91
8.1.230.0080.00424.01
8.1.220.0000.01017.74
8.1.210.0090.00018.77
8.1.200.0000.00917.36
8.1.190.0050.00317.35
8.1.180.0060.00318.10
8.1.170.0060.00318.40
8.1.160.0060.00318.91
8.1.150.0000.00718.91
8.1.140.0050.00219.00
8.1.130.0070.00020.21
8.1.120.0000.00717.50
8.1.110.0030.00517.50
8.1.100.0000.00817.50
8.1.90.0040.00417.39
8.1.80.0060.00317.47
8.1.70.0030.00517.46
8.1.60.0000.00817.52
8.1.50.0050.00317.45
8.1.40.0050.00317.53
8.1.30.0060.00317.59
8.1.20.0030.00517.64
8.1.10.0030.00517.61
8.1.00.0040.00417.55
8.0.300.0040.00420.09
8.0.290.0000.00716.75
8.0.280.0070.00018.35
8.0.270.0000.00818.02
8.0.260.0000.00818.38
8.0.250.0000.00716.88
8.0.240.0000.00716.87
8.0.230.0030.00516.99
8.0.220.0070.00316.93
8.0.210.0050.00216.96
8.0.200.0040.00416.94
8.0.190.0070.00016.91
8.0.180.0060.00317.00
8.0.170.0050.00316.95
8.0.160.0050.00216.84
8.0.150.0070.00016.95
8.0.140.0030.00616.77
8.0.130.0000.00613.34
8.0.120.0030.00516.89
8.0.110.0070.00016.88
8.0.100.0040.00416.95
8.0.90.0040.00416.78
8.0.80.0070.00916.90
8.0.70.0040.00416.79
8.0.60.0040.00416.91
8.0.50.0000.00716.95
8.0.30.0060.01117.11
8.0.20.0120.00816.92
8.0.10.0040.00416.99
8.0.00.0130.01016.86
7.4.330.0050.00015.55
7.4.320.0000.00616.52
7.4.300.0000.00616.57
7.4.290.0000.00816.54
7.4.280.0000.00816.57
7.4.270.0000.00816.64
7.4.260.0000.00613.30
7.4.250.0000.00816.53
7.4.240.0010.00616.53
7.4.230.0040.00416.51
7.4.220.0030.00316.57
7.4.210.0090.00816.59
7.4.200.0030.00316.73
7.4.130.0080.01216.52
7.4.120.0000.01916.58
7.4.110.0060.01216.63
7.4.100.0160.00316.52
7.4.90.0090.00916.59
7.4.80.0090.00919.39
7.4.70.0070.01016.66
7.4.60.0000.01816.46
7.4.50.0110.00916.41
7.4.40.0130.00316.52
7.4.30.0100.01016.66
7.4.20.0160.00316.49
7.4.10.0030.01316.27
7.4.00.0070.01016.70
7.3.330.0070.00016.45
7.3.320.0000.00513.45
7.3.310.0030.00316.23
7.3.300.0000.00716.27
7.3.290.0090.00616.38
7.3.280.0060.00916.36
7.3.260.0140.00316.45
7.3.240.0080.00816.48
7.3.230.0060.01216.41
7.3.210.0040.01316.41
7.3.200.0110.00616.48
7.3.190.0110.00616.68
7.3.180.0140.00316.38
7.3.170.0090.00916.43
7.3.160.0110.00516.41
7.3.150.0130.00516.63
7.3.140.0080.00816.43
7.3.130.0090.00616.49
7.3.120.0080.00816.40
7.3.110.0090.00916.55
7.3.100.0060.01016.43
7.3.90.0060.00916.16
7.3.80.0030.01316.34
7.3.70.0080.00816.31
7.3.60.0060.01316.34
7.3.50.0030.01416.43
7.3.40.0100.00916.41
7.3.30.0190.00316.47
7.3.20.0080.00816.57
7.3.10.0130.00616.40
7.3.00.0070.01016.41
7.2.330.0110.00716.84
7.2.320.0080.00816.59
7.2.310.0100.00716.85
7.2.300.0030.01416.66
7.2.290.0100.00816.71
7.2.280.0000.02016.86
7.2.270.0000.01616.81
7.2.260.0110.00416.66
7.2.250.0070.01116.61
7.2.240.0100.00716.82
7.2.230.0040.01616.65
7.2.220.0210.00316.79
7.2.210.0060.01216.46
7.2.200.0100.01016.65
7.2.190.0040.01416.63
7.2.180.0080.01116.65
7.2.170.0140.00516.44
7.2.160.0110.00816.84
7.2.150.0110.00616.63
7.2.140.0090.00916.81
7.2.130.0090.00916.74
7.2.120.0110.00716.62
7.2.110.0030.01616.55
7.2.100.0100.01016.63
7.2.90.0340.01216.84
7.2.80.0110.01416.53
7.2.70.0090.00916.56
7.2.60.0090.00916.71
7.2.50.0070.01416.70
7.2.40.0100.01116.71
7.2.30.0090.01016.68
7.2.20.0100.00816.80
7.2.10.0120.01216.67
7.2.00.0120.00916.76

preferences:
31.53 ms | 403 KiB | 5 Q