3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $id = 'id';; protected $displayName = 'name'; } class B implements ArrayAccess { public function offsetSet($offset, $value) { $offset = $this->_mapField($offset); $this->$offset = $value; } public function offsetExists($offset) { $offset = $this->_mapField($offset); return property_exists($this, $offset); } public function offsetUnset($offset) { $offset = $this->_mapField($offset); throw new \Exception("Cannot remove the property $offset"); } public function offsetGet($offset) { $offset = $this->_mapField($offset); if ($this->offsetExists($offset)) { return $this->$offset; } throw new \Exception("$offset property does not exists"); } private function _mapField($keyFrom) { if ($keyFrom === 'id_user') { return 'id'; } elseif ($keyFrom === 'name') { return 'displayName'; } return $keyFrom; } } $b = new B(); var_dump($b['id']); var_dump($b['id_user']); var_dump($b['displayName']); var_dump($b['name']);

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)
7.0.20.0270.06020.12
7.0.10.0070.09320.07
7.0.00.0100.07720.09
5.6.170.0300.07320.55
5.6.160.0030.07720.56
5.6.150.0070.08018.20
5.6.140.0100.08018.18
5.6.130.0030.08318.27
5.6.120.0070.08320.89
5.6.110.0170.07021.01
5.6.100.0100.07720.97
5.6.90.0100.03720.94
5.6.80.0030.07320.38
5.5.310.0330.07320.26
5.5.300.0030.05717.92
5.5.290.0030.04018.08
5.5.280.0170.07020.73
5.5.270.0030.09020.95
5.5.260.0070.07020.95
5.5.250.0000.05320.46
5.5.240.0170.03020.15

preferences:
141.08 ms | 1394 KiB | 7 Q