3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Field { private $value; private $data; /** * @return mixed */ public function getData() { return $this->data; } /** * @param mixed $data */ public function setData($data) { $this->data = $data; } public function getValue() { return $this->value; } public function setValue($value) { $this->value = $value; } public function __toString() { return $this->value; } } class BaseModel implements Iterator, ArrayAccess { private $data; /** * @var ArrayIterator */ protected $iterator; public function __construct() { $this->data = new StdClass(); $this->iterator = new ArrayIterator($this->data); } public function __set($key, $value) { if(!property_exists($this->data, $key)) { $this->data->{$key} = new Field(); } $this->data->{$key}->setValue($value); } public function __get($key) { if(property_exists($this->data, $key)) { return $this->data->{$key}; } return null; } public function __invoke() { echo "Invoke\n"; } /** * (PHP 5 &gt;= 5.0.0)<br/> * Return the current element * @link http://php.net/manual/en/iterator.current.php * @return mixed Can return any type. */ public function current() { return $this->iterator->current(); } /** * (PHP 5 &gt;= 5.0.0)<br/> * Move forward to next element * @link http://php.net/manual/en/iterator.next.php * @return void Any returned value is ignored. */ public function next() { $this->iterator->next(); } /** * (PHP 5 &gt;= 5.0.0)<br/> * Return the key of the current element * @link http://php.net/manual/en/iterator.key.php * @return mixed scalar on success, or null on failure. */ public function key() { return $this->iterator->key(); } /** * (PHP 5 &gt;= 5.0.0)<br/> * Checks if current position is valid * @link http://php.net/manual/en/iterator.valid.php * @return boolean The return value will be casted to boolean and then evaluated. * Returns true on success or false on failure. */ public function valid() { return $this->iterator->valid(); } /** * (PHP 5 &gt;= 5.0.0)<br/> * Rewind the Iterator to the first element * @link http://php.net/manual/en/iterator.rewind.php * @return void Any returned value is ignored. */ public function rewind() { $this->iterator->rewind(); } /** * (PHP 5 &gt;= 5.0.0)<br/> * Whether a offset exists * @link http://php.net/manual/en/arrayaccess.offsetexists.php * @param mixed $offset <p> * An offset to check for. * </p> * @return boolean true on success or false on failure. * </p> * <p> * The return value will be casted to boolean if non-boolean was returned. */ public function offsetExists($offset) { return property_exists($this, $offset); } /** * (PHP 5 &gt;= 5.0.0)<br/> * Offset to retrieve * @link http://php.net/manual/en/arrayaccess.offsetget.php * @param mixed $offset <p> * The offset to retrieve. * </p> * @return mixed Can return all value types. */ public function offsetGet($offset) { return $this->{$offset}; } /** * (PHP 5 &gt;= 5.0.0)<br/> * Offset to set * @link http://php.net/manual/en/arrayaccess.offsetset.php * @param mixed $offset <p> * The offset to assign the value to. * </p> * @param mixed $value <p> * The value to set. * </p> * @return void */ public function offsetSet($offset, $value) { $this->{$offset} = $value; } /** * (PHP 5 &gt;= 5.0.0)<br/> * Offset to unset * @link http://php.net/manual/en/arrayaccess.offsetunset.php * @param mixed $offset <p> * The offset to unset. * </p> * @return void */ public function offsetUnset($offset) { unset($this->{$offset}); } } /** * Class TestModel * @property Field test * @property Field test2 */ class TestModel extends BaseModel { } $t = new TestModel(); $t->test = 'test'; $t->test->setData('test data'); foreach ($t as $key => $value) { echo $key, '->', $value, "(", $value->getData() ,")\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.0070.00718.55
8.3.50.0070.00921.97
8.3.40.0040.01118.92
8.3.30.0120.00319.27
8.3.20.0060.00320.21
8.3.10.0080.00023.48
8.3.00.0040.00420.65
8.2.180.0110.01116.63
8.2.170.0110.00722.96
8.2.160.0140.00020.52
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00420.91
8.2.110.0090.00022.07
8.2.100.0070.01017.55
8.2.90.0000.00817.63
8.2.80.0030.00517.97
8.2.70.0090.00017.93
8.2.60.0080.00018.34
8.2.50.0040.00418.10
8.2.40.0040.00419.88
8.2.30.0030.00618.16
8.2.20.0050.00317.76
8.2.10.0000.00818.05
8.2.00.0080.00017.59
8.1.280.0110.01125.92
8.1.270.0040.00423.96
8.1.260.0000.00826.35
8.1.250.0070.00028.09
8.1.240.0050.00523.91
8.1.230.0070.00421.01
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0080.00517.35
8.1.190.0030.00617.23
8.1.180.0000.00919.32
8.1.170.0040.00418.37
8.1.160.0030.00522.12
8.1.150.0000.00818.55
8.1.140.0000.00817.50
8.1.130.0070.00017.85
8.1.120.0000.00717.55
8.1.110.0060.00317.44
8.1.100.0090.00017.42
8.1.90.0050.00217.50
8.1.80.0080.00017.46
8.1.70.0040.00417.49
8.1.60.0030.00617.52
8.1.50.0040.00417.57
8.1.40.0080.00017.46
8.1.30.0080.00017.52
8.1.20.0060.00317.70
8.1.10.0040.00417.59
8.1.00.0070.00017.43
8.0.300.0070.00019.84
8.0.290.0060.00316.63
8.0.280.0030.00318.46
8.0.270.0070.00017.21
8.0.260.0030.00317.24
8.0.250.0000.00716.98
8.0.240.0050.00217.03
8.0.230.0030.00316.84
8.0.220.0050.00216.89
8.0.210.0030.00316.82
8.0.200.0000.00817.03
8.0.190.0030.00617.01
8.0.180.0000.00716.84
8.0.170.0050.00316.88
8.0.160.0070.00016.90
8.0.150.0040.00416.95
8.0.140.0040.00416.89
8.0.130.0080.00013.39
8.0.120.0040.00416.89
8.0.110.0040.00416.83
8.0.100.0020.00516.87
8.0.90.0000.00716.80
8.0.80.0190.00316.92
8.0.70.0040.00416.75
8.0.60.0050.00216.79
8.0.50.0040.00416.91
8.0.30.0080.01117.04
8.0.20.0170.00617.40
8.0.10.0040.00417.08
8.0.00.0080.01016.62
7.4.330.0000.00515.00
7.4.320.0050.00316.54
7.4.300.0030.00316.63
7.4.290.0070.00016.56
7.4.280.0050.00316.43
7.4.270.0040.00416.57
7.4.260.0000.00716.52
7.4.250.0070.00016.53
7.4.240.0040.00416.61
7.4.230.0000.00716.64
7.4.220.0060.01516.49
7.4.210.0080.00916.62
7.4.200.0040.00416.66
7.4.190.0070.00016.70
7.4.160.0000.01616.46
7.4.150.0100.00917.40
7.4.140.0080.00917.86
7.4.130.0080.01016.54
7.4.120.0050.01116.56
7.4.110.0030.01316.35
7.4.100.0090.01316.66
7.4.90.0070.01416.66
7.4.80.0100.01019.39
7.4.70.0150.00316.42
7.4.60.0100.00716.43
7.4.50.0000.00416.53
7.4.40.0060.01016.61
7.4.30.0070.01016.54
7.4.00.0030.01215.10
7.3.330.0050.00013.46
7.3.320.0000.00513.26
7.3.310.0000.00716.45
7.3.300.0030.00516.52
7.3.290.0060.01016.44
7.3.280.0090.00716.39
7.3.270.0090.00917.40
7.3.260.0100.00716.57
7.3.250.0120.00516.64
7.3.240.0090.00916.62
7.3.230.0070.01016.66
7.3.210.0090.00916.46
7.3.200.0070.01119.39
7.3.190.0070.01016.56
7.3.180.0130.00316.35
7.3.170.0030.01216.69
7.3.160.0030.01316.54
7.3.120.0140.00315.13
7.3.10.0040.00816.80
7.3.00.0060.00616.74
7.2.330.0100.01416.73
7.2.320.0100.00716.87
7.2.310.0030.01316.85
7.2.300.0120.00616.86
7.2.290.0130.01016.57
7.2.130.0040.00416.69
7.2.120.0100.00317.09
7.2.110.0030.00717.11
7.2.100.0070.00417.00
7.2.90.0000.01317.00
7.2.80.0110.00016.91
7.2.70.0030.00817.01
7.2.60.0110.00416.67
7.2.50.0000.01117.11
7.2.40.0100.00716.91
7.2.30.0060.00616.77
7.2.20.0080.00017.01
7.2.10.0000.01116.74
7.2.00.0110.00418.25
7.1.250.0140.00015.83
7.1.100.0040.01118.31
7.1.70.0030.00617.22
7.1.60.0000.02519.46
7.1.50.0000.01216.98
7.1.00.0100.07022.48
7.0.200.0030.00616.84
7.0.140.0000.06721.98
7.0.60.0100.08019.83
7.0.50.0170.07317.93
7.0.40.0070.04320.15
7.0.30.0230.06720.26
7.0.20.0370.06720.07
7.0.10.0070.07720.04
7.0.00.0030.07020.24
5.6.280.0030.07321.17
5.6.210.0100.08020.59
5.6.200.0100.08018.29
5.6.190.0170.07320.39
5.6.180.0330.03720.48
5.6.170.0270.08320.50
5.6.160.0100.08320.41
5.6.150.0170.05318.25
5.6.140.0000.04318.16
5.6.130.0000.09318.18
5.6.120.0130.06321.00
5.6.110.0130.07721.15
5.6.100.0130.07721.13
5.6.90.0030.08720.99
5.6.80.0100.07720.39
5.5.350.0330.07720.36
5.5.340.0030.04017.98
5.5.330.0130.03320.45
5.5.320.0130.06320.24
5.5.310.0230.08020.35
5.5.300.0070.06017.94
5.5.290.0130.07718.07
5.5.280.0070.07320.90
5.5.270.0030.08720.75
5.5.260.0070.05020.82
5.5.250.0070.04020.71
5.5.240.0030.08020.28
5.4.450.0630.06019.56
5.4.440.0100.07019.31
5.4.430.0100.06319.43
5.4.420.0100.05319.53
5.4.410.0230.04019.20
5.4.400.0130.05319.34
5.4.390.0070.05719.12
5.4.380.0200.05718.75
5.4.370.0130.06318.84
5.4.360.0170.04718.75
5.4.350.0100.03612.04
5.4.340.0060.03512.04
5.4.320.0100.04112.53
5.4.310.0040.04812.52
5.4.300.0070.05112.52
5.4.290.0060.05512.52
5.4.280.0090.03712.42
5.4.270.0100.04012.42
5.4.260.0100.04012.42
5.4.250.0070.04412.41
5.4.240.0070.04112.42
5.4.230.0090.03812.41
5.4.220.0060.04112.41
5.4.210.0070.03812.41
5.4.200.0090.05012.41
5.4.190.0100.06212.41
5.4.180.0080.05412.41
5.4.170.0090.04812.41
5.4.160.0070.03912.41
5.4.150.0070.04212.41
5.4.140.0090.03812.10
5.4.130.0090.03912.08
5.4.120.0050.04012.04
5.4.110.0100.04012.04
5.4.100.0040.03812.03
5.4.90.0050.04012.04
5.4.80.0110.03712.03
5.4.70.0090.03712.03
5.4.60.0070.05712.03
5.4.50.0050.05812.03
5.4.40.0060.07212.02
5.4.30.0050.05212.02
5.4.20.0070.04912.02
5.4.10.0060.04012.02
5.4.00.0080.06411.51
5.3.290.0060.04412.80
5.3.280.0070.07412.71
5.3.270.0080.05712.73
5.3.260.0090.04312.72
5.3.250.0100.04412.72
5.3.240.0070.04512.72
5.3.230.0060.04612.71
5.3.220.0060.04612.68
5.3.210.0100.05612.68
5.3.200.0070.06512.68
5.3.190.0140.05712.68
5.3.180.0060.06312.68
5.3.170.0100.05612.68
5.3.160.0090.07112.68
5.3.150.0130.06412.68
5.3.140.0140.08412.66
5.3.130.0090.05812.66
5.3.120.0070.06712.66
5.3.110.0110.07512.66
5.3.100.0090.05312.15
5.3.90.0080.05012.13
5.3.80.0100.06812.12
5.3.70.0050.05112.13
5.3.60.0110.04312.11
5.3.50.0040.05212.05
5.3.40.0080.05312.05
5.3.30.0110.04312.01
5.3.20.0110.04311.79
5.3.10.0070.04011.76
5.3.00.0070.04011.75
5.2.170.0070.0319.25
5.2.160.0080.0499.26
5.2.150.0060.0339.26
5.2.140.0090.0449.25
5.2.130.0060.0329.22
5.2.120.0120.0329.21
5.2.110.0060.0459.22
5.2.100.0090.0319.21
5.2.90.0070.0349.22
5.2.80.0150.0579.21
5.2.70.0100.0329.21
5.2.60.0080.0349.17
5.2.50.0080.0349.14
5.2.40.0180.0539.11
5.2.30.0080.0339.09
5.2.20.0040.0369.08
5.2.10.0080.0378.98
5.2.00.0070.0348.85
5.1.60.0080.0418.13
5.1.50.0070.0258.13
5.1.40.0030.0298.10
5.1.30.0060.0278.46
5.1.20.0040.0308.48
5.1.10.0050.0378.21
5.1.00.0050.0408.21
5.0.50.0050.0286.68
5.0.40.0060.0286.55
5.0.30.0070.0386.36
5.0.20.0050.0276.33
5.0.10.0050.0286.31
5.0.00.0020.0446.30
4.4.90.0010.0254.78
4.4.80.0040.0224.75
4.4.70.0030.0234.76
4.4.60.0030.0224.75
4.4.50.0030.0234.77
4.4.40.0040.0344.71
4.4.30.0030.0234.76
4.4.20.0050.0224.84
4.4.10.0030.0234.85
4.4.00.0040.0344.76
4.3.110.0020.0244.66
4.3.100.0030.0234.66
4.3.90.0040.0204.63
4.3.80.0020.0324.59
4.3.70.0020.0214.63
4.3.60.0070.0164.63
4.3.50.0050.0194.63
4.3.40.0040.0304.54
4.3.30.0010.0223.30
4.3.20.0030.0213.29
4.3.10.0030.0213.24
4.3.00.0130.0238.02

preferences:
39.42 ms | 401 KiB | 5 Q