3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a implements \Iterator, \Countable, \ArrayAccess { private $a; private $b; private $c; private $keys = [ 'a', 'b', 'c' ]; private $pointer; public function __construct($a = null, $b = null, $c = null) { $this->a = $a; $this->b = $b; $this->c = $c; } public function count() { $pointer = 0; foreach ($this as $element) { if ($element) { $pointer++; } } return $pointer; } public function current() { $key = $this->key(); return $this->{$key}; } public function key() { return $this->keys[$this->pointer]; } public function next() { $this->pointer++; } public function valid() { return $this->pointer < count($this->keys); } public function rewind() { $this->pointer = 0; } public function offsetExists($offset) { return isset($this->{$offset}); } public function offsetGet($offset) { return $this->{$offset}; } public function offsetSet($offset, $value) { throw new \BadMethodCallException('Object does not implement set'); } public function offsetUnset($offset) { throw new \BadMethodCallException('Value object does not implement modification via unset'); } } $me = new a(1,2,3); var_dump($me->count()); var_dump($me['c']); foreach ($me as $key => $el) { if ($key === 'b') { $me[$key] = 111; } }

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.70.0090.01218.66
8.3.60.0150.00616.86
8.3.50.0100.01221.18
8.3.40.0180.00018.84
8.3.30.0030.01318.79
8.3.20.0000.00820.38
8.3.10.0040.00423.48
8.3.00.0080.00019.81
8.2.190.0130.00716.81
8.2.180.0040.01116.59
8.2.170.0150.00022.96
8.2.160.0100.01020.37
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0060.00317.75
8.2.110.0070.00321.10
8.2.100.0040.00717.84
8.2.90.0050.00317.88
8.2.80.0030.00518.98
8.2.70.0050.00317.75
8.2.60.0050.00317.75
8.2.50.0080.00018.05
8.2.40.0000.00818.09
8.2.30.0050.00218.23
8.2.20.0040.00417.94
8.2.10.0040.00418.06
8.2.00.0040.00418.21
8.1.280.0130.00625.92
8.1.270.0090.00020.24
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0090.00022.62
8.1.230.0080.00320.95
8.1.220.0030.00518.49
8.1.210.0050.00318.77
8.1.200.0030.00617.35
8.1.190.0000.00817.23
8.1.180.0000.00918.10
8.1.170.0050.00317.62
8.1.160.0000.00818.89
8.1.150.0040.00418.98
8.1.140.0000.00817.46
8.1.130.0070.00017.76
8.1.120.0030.00617.50
8.1.110.0040.00417.43
8.1.100.0050.00317.46
8.1.90.0040.00417.42
8.1.80.0040.00417.46
8.1.70.0000.00717.50
8.1.60.0000.01017.52
8.1.50.0030.00517.59
8.1.40.0030.00517.58
8.1.30.0090.00017.73
8.1.20.0050.00317.71
8.1.10.0040.00417.64
8.1.00.0020.00517.52
8.0.300.0100.00318.77
8.0.290.0080.00016.88
8.0.280.0030.00518.45
8.0.270.0040.00417.31
8.0.260.0000.00617.33
8.0.250.0060.00317.07
8.0.240.0070.00017.12
8.0.230.0000.00717.01
8.0.220.0040.00417.00
8.0.210.0040.00416.88
8.0.200.0000.00816.95
8.0.190.0080.00317.09
8.0.180.0000.00817.04
8.0.170.0000.00817.05
8.0.160.0040.00416.97
8.0.150.0040.00416.98
8.0.140.0030.00716.94
8.0.130.0000.00713.42
8.0.120.0050.00316.88
8.0.110.0000.00817.04
8.0.100.0040.00416.96
8.0.90.0040.00417.13
8.0.80.0070.00717.00
8.0.70.0030.00516.97
8.0.60.0040.00416.88
8.0.50.0000.00716.80
8.0.30.0130.00817.05
8.0.20.0070.01417.40
8.0.10.0000.00717.00
8.0.00.0110.00916.72
7.4.330.0000.00515.08
7.4.320.0030.00316.55
7.4.300.0030.00316.55
7.4.290.0000.00716.54
7.4.280.0000.00816.64
7.4.270.0000.00716.57
7.4.260.0040.00416.62
7.4.250.0050.00316.54
7.4.240.0010.00616.63
7.4.230.0030.00316.45
7.4.220.0070.01116.54
7.4.210.0000.01616.46
7.4.200.0000.00916.49
7.4.160.0060.00916.47
7.4.150.0120.00617.40
7.4.140.0070.01217.86
7.4.130.0140.00616.54
7.4.120.0080.00916.38
7.4.110.0100.00716.55
7.4.100.0130.00716.67
7.4.90.0160.00616.63
7.4.80.0060.01219.39
7.4.70.0120.00616.47
7.4.60.0100.00616.55
7.4.50.0050.00316.50
7.4.40.0040.01216.61
7.4.30.0070.01016.63
7.4.00.0070.00715.00
7.3.330.0050.00013.41
7.3.320.0060.00013.52
7.3.310.0070.00016.32
7.3.300.0060.00016.34
7.3.290.0060.01216.49
7.3.280.0060.01416.45
7.3.270.0120.00617.40
7.3.260.0090.00916.64
7.3.250.0110.00616.68
7.3.240.0060.01116.46
7.3.230.0070.01116.66
7.3.210.0070.01016.53
7.3.200.0100.01316.50
7.3.190.0130.00316.69
7.3.180.0070.01016.48
7.3.170.0130.00516.64
7.3.160.0090.01316.54
7.2.330.0180.00016.70
7.2.320.0140.00716.77
7.2.310.0030.01316.77
7.2.300.0070.01616.50
7.2.290.0090.00916.49
7.2.60.0070.00716.77
7.2.00.0000.01219.53
7.1.200.0100.00315.71
7.1.100.0140.00718.09
7.1.70.0000.01116.80
7.1.60.0040.00720.03
7.1.50.0060.00616.70
7.1.00.0030.07322.48
7.0.200.0080.00416.72
7.0.60.0170.07320.05
7.0.50.0100.07317.85
7.0.40.0070.05020.26
7.0.30.0270.08320.15
7.0.20.0330.05720.33
7.0.10.0070.09320.33
7.0.00.0130.05020.19
5.6.280.0070.06320.79
5.6.210.0000.07020.49
5.6.200.0130.03018.22
5.6.190.0070.08720.43
5.6.180.3970.03720.61
5.6.170.0300.07020.47
5.6.160.0170.07320.34
5.6.150.0100.03718.18
5.6.140.0100.07718.18
5.6.130.0170.04718.13
5.6.120.0070.07021.17
5.6.110.0130.08021.13
5.6.100.0130.07720.98
5.6.90.0130.08021.07
5.6.80.0230.05020.54
5.6.70.4470.04320.36
5.5.350.0000.08020.45
5.5.340.0070.05317.93
5.5.330.0000.06020.21
5.5.320.0270.05320.35
5.5.310.0170.04320.24
5.5.300.0170.04317.98
5.5.290.0000.08718.09
5.5.280.0070.08320.80
5.5.270.0170.05720.86
5.5.260.0170.07720.81
5.5.250.0170.07020.57
5.5.240.0330.04020.21
5.4.450.0070.04319.53
5.4.440.0030.06319.49
5.4.430.0000.04719.45
5.4.420.0000.04019.45
5.4.410.0070.03719.02
5.4.400.0030.04018.87
5.4.390.0030.05318.85
5.4.380.0070.05319.00
5.4.370.0130.07319.19
5.4.360.0170.03318.87
5.4.350.0100.03719.32
5.4.340.0070.04019.04
5.4.320.0170.03319.13
5.4.310.0130.03719.22
5.4.300.0170.03319.16
5.4.290.0130.03718.99
5.4.280.0100.04019.23
5.4.270.0100.04018.99
5.4.260.0100.04019.13
5.4.250.0170.04019.24
5.4.240.0100.04019.18
5.4.230.0130.04019.21
5.4.220.0200.07319.08
5.4.210.0270.06319.22
5.4.200.0170.07018.98
5.4.190.0270.06019.08
5.4.180.0370.06318.94
5.4.170.0270.07019.12
5.4.160.0170.07719.20
5.4.150.0200.05318.96
5.4.140.0170.05016.37
5.4.130.0270.05316.66
5.4.120.0300.06316.67
5.4.110.0170.05716.28
5.4.100.0170.05716.59
5.4.90.0130.06716.21
5.4.80.0100.07716.43

preferences:
43.28 ms | 401 KiB | 5 Q