3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Config implements ArrayAccess, Countable { /** * @var ArrayObject */ private $storage; /** * @param array $preset */ public function __construct($preset) { $this->storage = new ArrayObject($preset); $this->storage->setFlags( ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); } /** * ArrayAccess offsetGet (getter). * * @param string $index */ public function offsetGet($index) { return isset($this->storage->{$index}) ? $this->storage->{$index} : null; } /** * ArrayAccess offsetSet (setter). * * @param string $index * @param mixed $value */ public function offsetSet($index, $value) { if (is_null($index)) { $this->storage[] = $value; } else { $this->storage->{$index} = $value; } } /** * ArrayAccess offsetExists (isset). * * @param string $index */ public function offsetExists($index) { return isset($this->storage->{$index}); } /** * ArrayAccess offsetUnset (unset). * * @param string $index */ public function offsetUnset($index) { unset($this->storage->{$index}); } /** * Magic method (getter). * * @param string $index */ public function __get($index) { return $this->offsetGet($index); } /** * Magic method (setter). * * @param string $index * @param mixed $value */ public function __set($index, $value) { return $this->offsetSet($index, $value); } /** * Magic method (isset). * * @param string $index */ public function __isset($index) { return $this->offsetExists($index); } /** * Magic method (unset). * * @param string $index */ public function __unset($index) { return $this->offsetUnset($index); } /** * Magic method (as function invoker). * * @param mixed $arguments */ public function __invoke(...$arguments) { if (isset($this->storage->{$arguments[0]})) { return $this->storage->{$arguments[0]}; } } /** * Magic method (toString well json). */ public function __toString() { $return = []; foreach ($this->storage as $key => $value) { $return[$key] = $value; } return json_encode($return, JSON_PRETTY_PRINT); } /** * Magic method (override print_r/var_dump). */ public function __debugInfo() { $return = []; foreach ($this->storage as $key => $value) { $return[$key] = $value; } return $return; } /** * Implements Countable */ public function count() { return $this->storage->count(); } } $config = new Config([ 'url' => 'https://example.com', 'title' => 'My dynamic website' ]); echo $config->url.PHP_EOL; echo $config['title'].PHP_EOL; echo count($config).PHP_EOL; echo print_r($config, true).PHP_EOL; echo $config.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.0110.00823.92
8.4.110.0090.01018.75
8.4.100.0110.00618.03
8.4.90.0060.00318.09
8.4.80.0040.00517.86
8.4.70.0120.00818.05
8.4.60.0110.01117.91
8.4.50.0120.00917.67
8.4.40.0030.00718.01
8.4.30.0110.00917.64
8.4.20.0150.00417.88
8.4.10.0030.00618.02
8.3.250.0050.00618.77
8.3.240.0100.00917.39
8.3.230.0100.01016.57
8.3.220.0130.00617.17
8.3.210.0120.00716.91
8.3.200.0110.00716.76
8.3.190.0080.01116.92
8.3.180.0070.00218.68
8.3.170.0100.01016.90
8.3.160.0110.00718.54
8.3.150.0120.00617.11
8.3.140.0050.00319.17
8.3.130.0070.01418.33
8.3.120.0030.01318.91
8.3.110.0120.00020.94
8.3.100.0060.00924.06
8.3.90.0110.00726.77
8.3.80.0060.00316.63
8.3.70.0090.00916.75
8.3.60.0070.01116.63
8.3.50.0080.00517.54
8.3.40.0060.01018.79
8.3.30.0110.00718.79
8.3.20.0040.00421.95
8.3.10.0040.00421.90
8.3.00.0080.00019.79
8.2.290.0120.00720.82
8.2.280.0060.00518.68
8.2.270.0090.00916.93
8.2.260.0140.00416.63
8.2.250.0070.01116.47
8.2.240.0040.00417.08
8.2.230.0070.00322.58
8.2.220.0000.01037.54
8.2.210.0140.00326.77
8.2.200.0050.00518.41
8.2.190.0120.00316.63
8.2.180.0120.00918.41
8.2.170.0110.00422.96
8.2.160.0100.00320.35
8.2.150.0040.00424.18
8.2.140.0090.00324.66
8.2.130.0050.00326.16
8.2.120.0060.00319.82
8.2.110.0110.00021.18
8.2.100.0040.00718.03
8.2.90.0080.00018.03
8.2.80.0040.00418.22
8.2.70.0050.00317.63
8.2.60.0000.00817.63
8.2.50.0060.00318.10
8.2.40.0040.00420.55
8.2.30.0040.00419.41
8.2.20.0000.00718.11
8.2.10.0040.00418.27
8.2.00.0050.00318.18
8.1.330.0120.00822.15
8.1.320.0130.00616.52
8.1.310.0110.00416.65
8.1.300.0060.01320.23
8.1.290.0060.00330.84
8.1.280.0130.00725.92
8.1.270.0120.00623.84
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00623.80
8.1.230.0060.00622.69
8.1.220.0050.00317.77
8.1.210.0050.00318.77
8.1.200.0090.00017.48
8.1.190.0030.00617.35
8.1.180.0000.00818.10
8.1.170.0000.00818.91
8.1.160.0000.00818.92
8.1.150.0050.00319.11
8.1.140.0040.00417.64
8.1.130.0000.00718.94
8.1.120.0060.00317.48
8.1.110.0090.00517.38
8.1.100.0050.00217.53
8.1.90.0000.00717.48
8.1.80.0000.00717.46
8.1.70.0000.00717.37
8.1.60.0080.00417.60
8.1.50.0040.00417.52
8.1.40.0080.00017.54
8.1.30.0080.00017.50
8.1.20.0000.01017.59
8.1.10.0030.00617.49
8.1.00.0040.00417.55
8.0.300.0050.00319.98
8.0.290.0000.00716.63
8.0.280.0000.00718.43
8.0.270.0030.00316.91
8.0.260.0040.00419.05
8.0.250.0000.00717.05
8.0.240.0000.00816.85
8.0.230.0030.00516.98
8.0.220.0030.00316.80
8.0.210.0030.00316.88
8.0.200.0030.00316.87
8.0.190.0070.00016.96
8.0.180.0080.00017.00
8.0.170.0040.00816.95
8.0.160.0030.00516.95
8.0.150.0040.00716.87
8.0.140.0030.00516.77
8.0.130.0070.00013.34
8.0.120.0070.00016.78
8.0.110.0000.00716.94
8.0.100.0000.00716.73
8.0.90.0000.00716.75
8.0.80.0100.00716.88
8.0.70.0000.00717.04
8.0.60.0040.00416.75
8.0.50.0040.00416.86
8.0.30.0090.00917.27
8.0.20.0100.00817.40
8.0.10.0040.00417.04
8.0.00.0110.00716.62
7.4.330.0020.00215.55
7.4.320.0000.00616.43
7.4.300.0030.00316.45
7.4.290.0000.00716.45
7.4.280.0000.01016.50
7.4.270.0030.00316.48
7.4.260.0030.00316.38
7.4.250.0070.00016.58
7.4.240.0070.00016.68
7.4.230.0000.00716.61
7.4.220.0000.00816.52
7.4.210.0130.00516.55
7.4.200.0000.00716.72
7.4.160.0100.00716.57
7.4.140.0120.00717.86
7.4.130.0130.00616.64
7.4.120.0100.00916.61
7.4.110.0100.00716.43
7.4.100.0070.01016.62
7.4.90.0110.01116.68
7.4.80.0120.01519.39
7.4.70.0120.00316.33
7.4.60.0060.01016.42
7.4.50.0160.00016.53
7.4.40.0120.00616.56
7.4.10.0100.00715.06
7.4.00.0050.01314.93
7.3.330.0000.00513.39
7.3.320.0000.00613.24
7.3.310.0000.00716.24
7.3.300.0070.00016.24
7.3.290.0040.00416.27
7.3.280.0060.01216.38
7.3.260.0140.00516.54
7.3.240.0120.00516.62
7.3.230.0030.02016.61
7.3.210.0100.00716.33
7.3.200.0120.00816.43
7.3.190.0140.00316.53
7.3.180.0150.00616.36
7.3.170.0000.01816.32
7.3.160.0090.00616.61
7.3.130.0060.01215.10
7.3.120.0080.00914.97
7.3.110.0070.01014.91
7.3.100.0080.01014.89
7.3.90.0070.00714.82
7.3.80.0080.00514.83
7.3.70.0020.00814.77
7.3.60.0040.00914.86
7.3.50.0030.01114.77
7.3.40.0050.01014.83
7.3.30.0060.00514.79
7.3.20.0060.00816.62
7.3.10.0040.00916.67
7.3.00.0050.00916.67
7.2.330.0070.01116.80
7.2.320.0090.00916.69
7.2.310.0070.01316.91
7.2.300.0110.00516.76
7.2.290.0070.01316.63
7.2.260.0080.01115.24
7.2.250.0060.01115.09
7.2.240.0070.01215.15
7.2.230.0040.01115.20
7.2.220.0070.00815.17
7.2.210.0040.01215.02
7.2.200.0050.00815.11
7.2.190.0060.00714.96
7.2.180.0050.00915.15
7.2.170.0070.00715.04
7.2.160.0050.00914.92
7.2.150.0060.00817.03
7.2.140.0120.00516.75
7.2.130.0120.00417.05
7.2.120.0090.00717.00
7.2.110.0090.00916.98
7.2.100.0060.00916.80
7.2.90.0060.00717.11
7.2.80.0060.00816.83
7.2.70.0030.01117.15
7.2.60.0050.00816.81
7.2.50.0080.00716.93
7.2.40.0360.00717.46
7.2.30.0310.01117.36
7.2.20.0260.01117.22
7.2.10.0350.01017.38
7.2.00.0270.00617.13
7.1.330.0060.00915.75
7.1.320.0060.00715.76
7.1.310.0060.00815.77
7.1.300.0070.00515.85
7.1.290.0050.00915.70
7.1.280.0060.00815.72
7.1.270.0040.01015.79
7.1.260.0050.00915.81
7.1.250.0030.01015.81
7.1.240.0050.01115.67
7.1.230.0080.00615.67
7.1.220.0040.01115.75
7.1.210.0090.00315.78
7.1.200.0110.00515.74
7.1.190.0040.00915.64
7.1.180.0000.01215.69
7.1.170.0060.00815.67
7.1.160.0280.00916.05
7.1.150.0320.00616.27
7.1.140.0300.00716.13
7.1.130.0320.00816.03
7.1.120.0280.00916.20
7.1.110.0340.00715.94
7.1.100.0420.00815.93
7.1.90.0410.00916.14
7.1.80.0220.01215.90
7.1.70.0330.00815.65
7.1.60.0350.01221.55
7.1.50.0380.01021.41
7.1.40.0470.01121.26
7.1.30.0440.00521.36
7.1.20.0330.01121.34
7.1.10.0310.00615.48
7.1.00.0300.00815.55
7.0.330.0030.00715.35
7.0.320.0050.00415.44
7.0.310.0070.00515.40
7.0.300.0040.00615.52
7.0.290.0080.00715.36
7.0.280.0030.01015.51
7.0.270.0050.00815.51
7.0.260.0070.00515.30
7.0.250.0110.00515.39
7.0.240.0060.01015.50
7.0.230.0060.00915.38
7.0.220.0020.00915.55
7.0.210.0040.00815.29
7.0.200.0090.00515.41
7.0.190.0030.01315.59
7.0.180.0050.01015.52
7.0.170.0110.00215.34
7.0.160.0070.00715.43
7.0.150.0020.01315.38
7.0.140.0080.01015.30
7.0.130.0030.00615.34
7.0.120.0060.00415.59
7.0.110.0030.01215.48
7.0.100.0050.00715.43
7.0.90.0020.01015.30
7.0.80.0060.00715.31
7.0.70.0060.00515.44
7.0.60.0070.00715.32
7.0.50.0090.00415.54
7.0.40.0030.00813.60
7.0.30.0040.00713.52
7.0.20.0040.01113.52
7.0.10.0000.01213.58
7.0.00.0060.00613.46
5.6.400.0030.01114.79
5.6.390.0050.01014.66
5.6.380.0070.00514.56
5.6.370.0100.00514.54
5.6.360.0020.01214.35
5.6.350.0060.00414.46
5.6.340.0100.00614.39
5.6.330.0060.00814.60
5.6.320.0060.00714.59
5.6.310.0030.01014.76
5.6.300.0080.00914.29
5.6.290.0080.00914.44
5.6.280.0030.00714.44
5.6.270.0080.00614.57
5.6.260.0070.00714.69
5.6.250.0070.00614.47
5.6.240.0050.00914.50
5.6.230.0030.00914.40
5.6.220.0080.00614.54
5.6.210.0040.00814.68
5.6.200.0050.00814.44
5.6.190.0040.00714.54
5.6.180.0050.00814.45
5.6.170.0140.00314.51
5.6.160.0070.00914.59
5.6.150.0010.00714.31
5.6.140.0070.00614.28
5.6.130.0070.00414.30
5.6.120.0060.00514.45
5.6.110.0060.00814.36
5.6.100.0030.00514.24
5.6.90.0050.00714.47
5.6.80.0080.00814.22
5.6.70.0060.00814.32
5.6.60.0100.00614.41
5.6.50.0090.00414.48
5.6.40.0020.01114.38
5.6.30.0060.00514.26
5.6.20.0060.00614.34
5.6.10.0030.00814.58
5.6.00.0060.00614.26

preferences:
120.58 ms | 403 KiB | 5 Q