3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private static $data; private $var = array(1,2,3); private $current; private $rewind; private $key; public function __construct($array = null) { if (is_array($array)) { $this->var = $array; } } public function __set($name, $value) { return $this->var[$name] = $value; } public function __get($name) { if (isset($this->var[$name])) { return $this->var[$name]; } } public function many() { if($this->rewind){ echo 'VAR2' . PHP_EOL; self::$data = array(88,99,11); } return self::$data[$this->key]; } public function manys() { if($this->rewind){ echo 'VAR' . PHP_EOL; self::$data = array(55,66,77); } return self::$data[$this->key]; } public function rewind() { self::$data = null; $this->rewind = 1; echo "rewinding\n"; reset($this->var); } public function current() { $var = current($this->var); $this->current = $var; echo "current: $var\n"; return $var; } public function key() { $var = key($this->var); $this->key = $var; echo "key: $var\n"; return $var; } public function next() { $var = next($this->var); echo "next: $var\n"; return $var; } public function valid() { $key = key($this->var); $var = ($key !== NULL && $key !== FALSE); echo "valid: $var\n"; if(! $var){ $this->rewind = 0; } return $var; } } class foo extends MyIterator{ public function test(){ return $this->many(); } public function test2(){ return $this->manys(); } } $it = new foo(); foreach ($it as $a => $b) { echo PHP_EOL . $it->test() . PHP_EOL . PHP_EOL; echo PHP_EOL . $it->test2() . PHP_EOL . PHP_EOL; print "$a: $b\n"; }

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.0120.00316.88
8.3.50.0110.00416.68
8.3.40.0120.00318.97
8.3.30.0120.00318.84
8.3.20.0080.00020.14
8.3.10.0000.00821.73
8.3.00.0070.00022.04
8.2.180.0140.00716.71
8.2.170.0120.00322.96
8.2.160.0070.00719.08
8.2.150.0090.00624.18
8.2.140.0040.00424.66
8.2.130.0040.00420.96
8.2.120.0020.00526.35
8.2.110.0000.01022.14
8.2.100.0080.00417.78
8.2.90.0040.00419.17
8.2.80.0080.00018.04
8.2.70.0060.00317.63
8.2.60.0030.00517.93
8.2.50.0030.00518.10
8.2.40.0050.00320.45
8.2.30.0000.00819.32
8.2.20.0050.00218.13
8.2.10.0000.00718.20
8.2.00.0040.00418.13
8.1.280.0140.00325.92
8.1.270.0070.00022.20
8.1.260.0070.00026.35
8.1.250.0070.00028.09
8.1.240.0000.01023.97
8.1.230.0100.00017.89
8.1.220.0040.00417.77
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0030.00617.23
8.1.180.0050.00318.10
8.1.170.0090.00020.75
8.1.160.0000.00718.95
8.1.150.0000.00818.79
8.1.140.0020.00519.48
8.1.130.0080.00018.95
8.1.120.0000.00817.51
8.1.110.0040.00417.45
8.1.100.0040.00417.37
8.1.90.0040.00417.38
8.1.80.0000.00717.45
8.1.70.0050.00217.37
8.1.60.0000.00817.64
8.1.50.0000.00917.55
8.1.40.0060.00317.38
8.1.30.0030.00517.64
8.1.20.0000.00817.70
8.1.10.0000.00917.64
8.1.00.0000.00717.38
8.0.300.0000.00718.77
8.0.290.0040.00416.75
8.0.280.0040.00418.52
8.0.270.0000.00717.23
8.0.260.0000.00716.85
8.0.250.0040.00417.01
8.0.240.0000.00716.96
8.0.230.0050.00217.05
8.0.220.0030.00316.91
8.0.210.0030.00516.91
8.0.200.0030.00316.90
8.0.190.0040.00416.98
8.0.180.0040.00416.97
8.0.170.0040.00416.86
8.0.160.0050.00316.93
8.0.150.0000.00816.88
8.0.140.0000.00716.82
8.0.130.0060.00313.43
8.0.120.0000.00816.92
8.0.110.0050.00216.90
8.0.100.0050.00316.98
8.0.90.0040.00416.96
8.0.80.0090.01216.90
8.0.70.0030.00616.98
8.0.60.0040.00416.74
8.0.50.0000.00816.78
8.0.30.0070.01117.14
8.0.20.0120.00617.42
8.0.10.0000.00817.08
8.0.00.0110.00816.89
7.4.330.0000.00515.55
7.4.320.0030.00316.64
7.4.300.0060.00016.62
7.4.290.0000.00816.51
7.4.280.0050.00516.65
7.4.270.0080.00016.51
7.4.260.0040.00416.46
7.4.250.0000.00816.55
7.4.240.0000.00716.61
7.4.230.0040.00416.52
7.4.220.0030.01516.56
7.4.210.0030.01116.44
7.4.200.0000.00816.36
7.4.160.0080.00816.62
7.4.150.0130.00417.40
7.4.140.0070.01317.86
7.4.130.0110.01216.58
7.4.120.0080.01216.60
7.4.110.0030.01316.54
7.4.100.0150.01516.70
7.4.90.0080.00916.62
7.4.80.0120.00619.39
7.4.70.0030.01216.62
7.4.60.0060.00916.49
7.4.50.0090.00616.26
7.4.40.0000.01716.64
7.4.30.0070.01416.44
7.4.10.0070.01015.05
7.4.00.0070.00814.80
7.3.330.0040.00313.41
7.3.320.0050.00013.39
7.3.310.0030.00316.41
7.3.300.0030.00316.46
7.3.290.0070.00916.34
7.3.280.0100.00816.39
7.3.270.0100.00717.40
7.3.260.0060.01116.45
7.3.250.0100.00916.47
7.3.240.0110.00616.60
7.3.230.0100.01016.55
7.3.210.0160.00016.43
7.3.200.0090.01316.41
7.3.190.0080.00816.34
7.3.180.0090.00616.58
7.3.170.0060.01016.50
7.3.160.0070.01016.56
7.3.130.0090.00914.88
7.3.120.0080.00714.74
7.3.110.0070.00714.88
7.3.100.0020.01315.01
7.3.90.0020.01014.75
7.3.80.0050.00914.84
7.3.70.0040.00914.78
7.3.60.0070.00614.83
7.3.50.0050.00914.81
7.3.40.0060.00814.77
7.3.30.0060.00914.67
7.3.20.0060.00916.69
7.3.10.0040.01016.72
7.3.00.0070.01016.64
7.2.330.0110.00816.82
7.2.320.0130.00416.76
7.2.310.0130.01016.85
7.2.300.0150.00616.72
7.2.290.0130.00916.87
7.2.260.0030.01514.93
7.2.250.0110.00715.00
7.2.240.0100.00514.91
7.2.230.0060.01115.02
7.2.220.0100.00515.13
7.2.210.0070.00515.13
7.2.200.0030.00915.05
7.2.190.0080.00815.18
7.2.180.0050.00915.05
7.2.170.0050.00915.03
7.2.160.0080.00515.05
7.2.150.0080.01016.90
7.2.140.0050.00916.86
7.2.130.0070.00617.00
7.2.120.0060.00916.89
7.2.110.0050.00916.80
7.2.100.0070.00517.06
7.2.90.0250.01016.43
7.2.80.0090.00916.47
7.2.70.0080.00716.52
7.2.60.0090.00616.27
7.2.50.0430.00816.42
7.2.40.0110.01116.49
7.2.30.0110.00616.50
7.2.20.0080.00916.50
7.2.10.0070.00916.44
7.2.00.0240.00916.50
7.1.330.0050.00815.78
7.1.320.0090.00715.67
7.1.310.0020.01215.72
7.1.300.0020.01215.90
7.1.290.0080.00515.93
7.1.280.0100.00415.74
7.1.270.0040.00915.87
7.1.260.0050.00715.70
7.1.250.0030.01015.89
7.1.240.0050.00715.80
7.1.230.0030.01015.81
7.1.220.0020.01015.61
7.1.210.0090.00615.10
7.1.200.0140.00515.05
7.1.190.0110.00715.03
7.1.180.0110.00615.08
7.1.170.0220.01015.05
7.1.160.0070.00615.22
7.1.150.0090.00615.09
7.1.140.0380.00914.98
7.1.130.0070.00815.20
7.1.120.0070.00915.18
7.1.110.0090.00715.33
7.1.100.0150.00715.13
7.1.90.0590.00615.09
7.1.80.0620.00715.02
7.1.70.0550.00515.11
7.1.60.0130.00621.08
7.1.50.0690.00921.11
7.1.40.0550.00721.08
7.1.30.0200.00521.02
7.1.20.0120.00921.20
7.1.10.0060.00815.10
7.1.00.0060.00915.23
7.0.330.0030.00915.35
7.0.320.0030.01015.27
7.0.310.0080.00714.70
7.0.300.0100.00614.65
7.0.290.0090.00614.78
7.0.280.0080.00714.60
7.0.270.0070.00814.64
7.0.260.0120.00314.53
7.0.250.0070.00814.50
7.0.240.0070.00814.70
7.0.230.0510.01114.86
7.0.220.0710.00514.74
7.0.210.0460.00614.77
7.0.200.0040.01014.82
7.0.190.0380.01114.79
7.0.180.0200.00914.61
7.0.170.0250.00814.82
7.0.160.0360.00714.83
7.0.150.0080.00814.77
7.0.140.0210.00314.61
7.0.130.0320.00914.85
7.0.120.0060.00914.69
7.0.110.0090.00614.66
7.0.100.0390.00714.59
7.0.90.0070.00614.78
7.0.80.0080.00614.73
7.0.70.0410.01014.70
7.0.60.0050.00914.76
7.0.50.0170.00714.83
7.0.40.0070.00813.54
7.0.30.0090.01113.54
7.0.20.0080.00913.37
7.0.10.0120.00813.39
7.0.00.0120.00713.54
5.6.400.0050.01214.42
5.6.390.0070.00714.44
5.6.380.0050.00814.27
5.6.370.0080.00614.29
5.6.360.0060.00714.43
5.6.350.0040.00714.36
5.6.340.0030.01014.41
5.6.330.0070.00514.57
5.6.320.0050.01114.37
5.6.310.0050.00814.16
5.6.300.0050.00714.31
5.6.290.0030.01114.27
5.6.280.0030.00714.33
5.6.270.0080.00814.28
5.6.260.0050.01014.26
5.6.250.0080.00314.52
5.6.240.0050.00814.39
5.6.230.0030.01114.17
5.6.220.0050.00914.18
5.6.210.0050.00514.29
5.6.200.0030.01014.30
5.6.190.0090.00514.50
5.6.180.0030.01114.51
5.6.170.0060.00614.19
5.6.160.0050.00914.23
5.6.150.0070.00414.42
5.6.140.0050.00914.54
5.6.130.0060.00914.40
5.6.120.0070.01014.47
5.6.110.0130.00214.30
5.6.100.0090.00514.34
5.6.90.0100.00514.32
5.6.80.0070.00814.28
5.6.70.0080.00514.41
5.6.60.0050.00514.31
5.6.50.0060.00814.33
5.6.40.0080.00614.28
5.6.30.0070.00614.22
5.6.20.0070.00914.13
5.6.10.0070.00714.22
5.6.00.0060.00714.47

preferences:
42.6 ms | 400 KiB | 5 Q