3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Item { private $cost = 100; public function getTotal($discount = 7) { return $this->cost * $discount/(100+$discount); } } class AccesserToPrivated { public function getPrivate($obj, $attribute) { $getter = function() use ($attribute) {return $this->$attribute;}; return \Closure::bind($getter, $obj, get_class($obj)); } public function setPrivate($obj, $attribute) { $setter = function($value) use ($attribute) {$this->$attribute = $value;}; return \Closure::bind($setter, $obj, get_class($obj)); } } $obj = new Item(); $accesser = new AccesserToPrivated(); $getFoo = $accesser->getPrivate($obj, 'cost'); $setFoo = $accesser->setPrivate($obj, 'cost'); echo $obj->getTotal() . PHP_EOL; echo getFoo() . PHP_EOL; $setFoo(1); //set new cost echo $obj->getTotal() . PHP_EOL; echo getFoo() . 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.3.40.0110.00318.98
8.3.30.0040.01118.83
8.3.20.0070.00020.34
8.3.10.0050.00221.85
8.3.00.0050.00323.51
8.2.170.0030.01022.96
8.2.160.0100.00319.46
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0040.00420.69
8.2.120.0030.00526.35
8.2.110.0030.00620.96
8.2.100.0040.00818.16
8.2.90.0060.00319.21
8.2.80.0000.00817.97
8.2.70.0100.00017.34
8.2.60.0030.00617.93
8.2.50.0040.00418.09
8.2.40.0090.00020.58
8.2.30.0040.00719.52
8.2.20.0060.00317.64
8.2.10.0020.00518.07
8.2.00.0040.00417.95
8.1.270.0130.00622.06
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0030.00622.41
8.1.230.0000.01117.83
8.1.220.0000.00817.74
8.1.210.0080.00018.77
8.1.200.0030.00617.13
8.1.190.0040.00417.35
8.1.180.0030.00618.10
8.1.170.0040.00418.52
8.1.160.0040.00420.85
8.1.150.0000.00818.89
8.1.140.0040.00419.55
8.1.130.0030.00317.82
8.1.120.0110.00017.38
8.1.110.0000.00717.47
8.1.100.0020.00517.44
8.1.90.0050.00317.37
8.1.80.0000.00717.51
8.1.70.0000.00717.37
8.1.60.0030.00617.49
8.1.50.0000.00817.52
8.1.40.0000.00817.52
8.1.30.0030.00617.66
8.1.20.0080.00017.55
8.1.10.0030.00517.49
8.1.00.0070.00017.54
8.0.300.0000.00818.78
8.0.290.0000.00716.75
8.0.280.0000.00718.39
8.0.270.0000.00717.28
8.0.260.0060.00017.20
8.0.250.0000.00716.93
8.0.240.0040.00417.04
8.0.230.0070.00016.94
8.0.220.0040.00416.92
8.0.210.0020.00516.96
8.0.200.0000.00617.04
8.0.190.0000.00817.07
8.0.180.0040.00416.89
8.0.170.0080.00316.95
8.0.160.0000.00717.00
8.0.150.0040.00416.82
8.0.140.0050.00316.83
8.0.130.0000.00513.39
8.0.120.0040.00416.94
8.0.110.0070.00016.90
8.0.100.0000.00717.03
8.0.90.0040.00416.86
8.0.80.0100.00716.94
8.0.70.0030.00316.84
8.0.60.0040.00416.84
8.0.50.0030.00416.86
8.0.30.0100.00617.08
8.0.20.0170.00417.40
8.0.10.0050.00216.96
8.0.00.0120.01116.89
7.4.330.0000.00516.73
7.4.320.0070.00016.38
7.4.300.0060.00016.51
7.4.290.0050.00316.57
7.4.280.0040.00716.48
7.4.270.0030.00316.51
7.4.260.0000.00716.64
7.4.250.0040.00416.46
7.4.240.0030.00316.61
7.4.230.0030.00316.70
7.4.220.0030.01816.55
7.4.210.0090.00816.58
7.4.200.0070.00016.41
7.4.160.0040.01416.73
7.4.150.0090.00917.40
7.4.140.0120.00517.86
7.4.130.0100.00816.48
7.4.120.0120.00516.56
7.4.110.0090.01216.79
7.4.100.0100.01316.56
7.4.90.0090.00916.63
7.4.80.0070.01119.39
7.4.70.0100.00616.59
7.4.60.0070.01116.71
7.4.50.0030.01016.51
7.4.40.0030.01716.50
7.4.30.0070.01116.73
7.4.00.0080.00614.87
7.3.330.0120.00013.41
7.3.320.0030.00313.48
7.3.310.0030.00316.48
7.3.300.0030.00316.37
7.3.290.0000.00716.33
7.3.280.0120.00516.45
7.3.270.0110.00717.40
7.3.260.0030.01416.43
7.3.250.0130.00716.46
7.3.240.0030.01516.45
7.3.230.0030.01316.43
7.3.210.0150.00316.67
7.3.200.0030.01319.39
7.3.190.0100.01016.39
7.3.180.0120.00916.43
7.3.170.0130.01016.62
7.3.160.0100.00716.59
7.3.120.0030.01314.90
7.3.110.0090.00914.72
7.3.100.0040.01115.01
7.3.90.0070.00714.71
7.3.80.0100.00714.89
7.3.70.0040.01114.92
7.3.60.0070.00714.73
7.3.50.0100.00314.95
7.3.40.0080.00414.70
7.3.30.0030.01014.96
7.3.20.0080.00616.63
7.3.10.0000.01616.75
7.3.00.0040.00916.71
7.2.330.0130.00416.86
7.2.320.0120.00916.79
7.2.310.0080.00816.70
7.2.300.0030.01316.74
7.2.290.0150.00016.83
7.2.250.0040.01814.91
7.2.240.0120.00815.38
7.2.230.0090.00315.27
7.2.220.0000.01015.08
7.2.210.0090.00915.27
7.2.200.0060.00614.88
7.2.190.0070.00715.08
7.2.180.0060.00915.08
7.2.170.0070.00414.97
7.2.130.0070.00416.92
7.2.120.0080.00816.88
7.2.110.0060.00617.00
7.2.100.0030.00916.90
7.2.90.0000.01117.15
7.2.80.0050.00516.94
7.2.70.0000.01316.93
7.2.60.0050.01016.98
7.2.50.0130.00016.80
7.2.40.0080.00416.94
7.2.30.0040.00816.81
7.2.20.0040.00816.96
7.2.10.0070.00716.78
7.2.00.0030.01018.06
7.1.330.0030.01315.70
7.1.320.0030.00715.71
7.1.310.0000.01515.66
7.1.300.0080.00815.59
7.1.290.0060.00615.77
7.1.280.0080.00615.66
7.1.270.0060.00615.88
7.1.260.0080.00415.87
7.1.250.0030.01016.02
7.1.240.0030.00915.84
7.1.230.0080.00015.82
7.1.220.0030.00815.53
7.1.210.0030.00915.99
7.1.200.0100.00315.80
7.1.190.0030.00915.84
7.1.180.0000.01015.55
7.1.170.0120.00315.70
7.1.160.0030.00615.82
7.1.150.0030.00615.77
7.1.140.0070.00315.83
7.1.130.0090.00615.91
7.1.120.0040.01015.84
7.1.110.0070.00715.91
7.1.100.0040.00716.91
7.1.90.0130.00015.89
7.1.80.0070.00315.80
7.1.70.0010.00916.54
7.1.60.0050.00917.66
7.1.50.0040.00816.30
7.1.40.0000.01015.69
7.1.30.0090.00615.63
7.1.20.0060.00315.81
7.1.10.0060.00315.74
7.1.00.0050.04219.11
7.0.330.0060.00615.29
7.0.320.0090.00315.32
7.0.310.0030.01015.53
7.0.300.0000.01015.49
7.0.290.0130.00014.98
7.0.280.0000.00715.19
7.0.270.0000.01515.32
7.0.260.0030.00615.36
7.0.250.0060.00315.52
7.0.240.0000.00915.43
7.0.230.0100.00015.63
7.0.220.0030.00615.55
7.0.210.0030.00715.37
7.0.200.0080.00615.07
7.0.190.0040.00815.44
7.0.180.0030.00915.58
7.0.170.0030.00615.14
7.0.160.0040.00715.42
7.0.150.0000.01115.45
7.0.140.0000.01315.18
7.0.130.0030.01015.41
7.0.120.0030.00615.38
7.0.110.0100.00015.15
7.0.100.0040.00915.48
7.0.90.0080.00415.49
7.0.80.0070.00315.60
7.0.70.0030.00715.46
7.0.60.0170.04417.42
7.0.50.0100.03616.50
7.0.40.0070.02716.88
7.0.30.0200.03516.67
7.0.20.0270.02716.83
7.0.10.0050.02816.69
7.0.00.0050.02516.87
5.6.380.0030.00614.36
5.6.370.0080.00414.57
5.6.360.0070.00414.31
5.6.350.0030.00814.39
5.6.340.0030.01014.63
5.6.330.0070.00314.45
5.6.320.0060.00614.68
5.6.310.0030.00714.52
5.6.300.0000.01114.56
5.6.290.0090.00314.30
5.6.280.0050.02117.88
5.6.270.0030.00814.47
5.6.260.0090.00314.35
5.6.250.0040.00414.28
5.6.240.0040.00714.53
5.6.230.0080.00014.13
5.6.220.0030.00914.45
5.6.210.0100.02617.44
5.6.200.0020.05016.16
5.6.190.0050.02417.50
5.6.180.0180.03017.43
5.6.170.0130.04017.47
5.6.160.0070.04317.31
5.6.150.0110.03616.40
5.6.140.0070.02516.39
5.6.130.0050.04216.33
5.6.120.0050.03217.72
5.6.110.0060.04317.76
5.6.100.0070.04517.49
5.6.90.0100.04317.63
5.6.80.0020.02617.25
5.6.70.0070.00014.13
5.6.60.0100.00714.10
5.6.50.0070.00713.95
5.6.40.0040.01114.30
5.6.30.0000.01414.54
5.6.20.0090.00313.92
5.6.10.0100.00014.25
5.6.00.0050.00514.04
5.5.380.0030.00311.09
5.5.370.0030.00811.23
5.5.360.0000.00811.24
5.5.350.0150.03015.80
5.5.340.0050.04314.69
5.5.330.0030.03815.74
5.5.320.0200.02515.84
5.5.310.0130.02015.75
5.5.300.0030.04614.69
5.5.290.0050.03614.71
5.5.280.0080.04016.19
5.5.270.0080.02315.93
5.5.260.0050.03516.05
5.5.250.0030.02615.91
5.5.240.1950.02315.64
5.5.230.0000.00811.17
5.5.220.0000.01010.93
5.5.210.0030.00611.11
5.5.200.0000.00510.94
5.5.190.0080.00011.25
5.5.180.0040.00410.88
5.5.170.0000.00811.24
5.5.160.0000.00611.20
5.5.150.0000.00610.71
5.5.140.0080.00011.05
5.5.130.0030.00311.13
5.5.120.0060.00611.17
5.5.110.0070.00011.28
5.5.100.0000.00511.38
5.5.90.0120.00011.16
5.5.80.0050.00311.25
5.5.70.0040.00411.17
5.5.60.0040.00411.15
5.5.50.0030.00711.24
5.5.40.0040.00411.21
5.5.30.0080.00011.09
5.5.20.0060.00611.30
5.5.10.0050.00011.11
5.5.00.0040.00411.18

preferences:
52.47 ms | 400 KiB | 5 Q