3v4l.org

run code in 300+ PHP versions simultaneously
<?php # The blueprint for designing creatures for your game interface LivingBeing { public function dealDamage(LivingBeing $opponent); public function takeDamage(int $damage); } interface Race { public function raceName(): string; } class Human implements LivingBeing, Race { private $hp = 150; private $offensiveStrength = 30; public function dealDamage(LivingBeing $opponent) { $opponent->takeDamage($this->offensiveStrength); } public function takeDamage(int $opponent) { } public function raceName(): string { return 'Human'; } } class Elf implements LivingBeing, Race { private $hp = 100; private $offensiveStrength = 30; public function dealDamage(LivingBeing $opponent) { $opponent->takeDamage($this->offensiveStrength); } public function takeDamage(int $opponent) { } public function raceName(): string { return 'Elf'; } } class Dwarf implements LivingBeing, Race { private $hp = 300; private $offensiveStrength = 30; public function dealDamage(LivingBeing $opponent) { $opponent->takeDamage($this->offensiveStrength); } public function takeDamage(int $opponent) { } public function raceName(): string { return 'Dwarf'; } } # I am a junior dev, I am just going to write this code class Centaur implements LivingBeing, Race { private $hp = 300; private $offensiveStrength = 30; public function dealDamage(LivingBeing $opponent) { $opponent->takeDamage($this->offensiveStrength); } public function takeDamage(int $opponent) { } public function raceName(): string { return 'Centaur'; } } class Orc implements LivingBeing, Race { private $hp = 300; private $offensiveStrength = 30; public function dealDamage(LivingBeing $opponent) { $opponent->takeDamage($this->offensiveStrength); } public function takeDamage(int $opponent) { } public function raceName(): string { return 'Orc'; } } function listTheirRace (Race ...$list) { $string = ''; foreach ($list as $being) { $string .= $being->raceName() . "\n"; } return $string; } $Adam = new Human; $Lucas = new Elf; $Jack = new Dwarf; # Let's fight! $Gabrielle = new Centaur; $Guthakug = new Orc; echo listTheirRace(...[$Adam, $Lucas, $Jack, $Gabrielle, $Guthakug]);

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.0100.00718.55
8.3.50.0150.00317.94
8.3.40.0070.00718.83
8.3.30.0150.00018.81
8.3.20.0040.00420.90
8.3.10.0060.00321.72
8.3.00.0000.00822.58
8.2.180.0170.00316.50
8.2.170.0140.00422.96
8.2.160.0180.00321.19
8.2.150.0000.00824.18
8.2.140.0000.00724.66
8.2.130.0140.00426.16
8.2.120.0040.00419.48
8.2.110.0060.00322.16
8.2.100.0080.00417.84
8.2.90.0000.00817.63
8.2.80.0060.00317.97
8.2.70.0000.00817.90
8.2.60.0060.00617.81
8.2.50.0090.00018.10
8.2.40.0000.00919.48
8.2.30.0070.00019.38
8.2.20.0040.00418.13
8.2.10.0050.00219.27
8.2.00.0040.00418.38
8.1.280.0170.00325.92
8.1.270.0080.00020.32
8.1.260.0090.00026.35
8.1.250.0050.00328.09
8.1.240.0080.00022.18
8.1.230.0090.00319.04
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0040.00417.48
8.1.190.0000.00816.98
8.1.180.0030.00618.10
8.1.170.0040.00418.65
8.1.160.0000.00718.90
8.1.150.0040.00418.91
8.1.140.0040.00418.98
8.1.130.0030.00320.19
8.1.120.0040.00417.48
8.1.110.0070.00017.37
8.1.100.0070.00317.34
8.1.90.0030.00517.48
8.1.80.0040.00417.50
8.1.70.0020.00517.39
8.1.60.0000.00817.60
8.1.50.0030.00617.37
8.1.40.0030.00617.43
8.1.30.0080.00317.73
8.1.20.0060.00317.64
8.1.10.0000.00817.59
8.1.00.0050.00317.59
8.0.300.0070.00019.74
8.0.290.0000.00916.75
8.0.280.0040.00418.46
8.0.270.0000.00717.31
8.0.260.0030.00318.46
8.0.250.0040.00416.91
8.0.240.0030.00316.97
8.0.230.0080.00016.84
8.0.220.0030.00416.92
8.0.210.0000.00716.84
8.0.200.0000.00716.93
8.0.190.0040.00416.99
8.0.180.0000.00716.80
8.0.170.0030.00616.89
8.0.160.0040.00416.95
8.0.150.0040.00416.81
8.0.140.0000.00816.73
8.0.130.0060.00013.37
8.0.120.0000.00816.90
8.0.110.0040.00416.91
8.0.100.0040.00416.83
8.0.90.0040.00416.84
8.0.80.0090.00616.84
8.0.70.0040.00416.79
8.0.60.0000.00816.84
8.0.50.0050.00316.75
8.0.30.0100.01317.20
8.0.20.0160.00916.93
8.0.10.0030.00416.85
8.0.00.0080.01116.87
7.4.330.0070.00015.55
7.4.320.0060.00016.47
7.4.300.0060.00016.52
7.4.290.0020.00516.52
7.4.280.0000.00816.46
7.4.270.0040.00416.57
7.4.260.0000.00716.40
7.4.250.0000.00716.43
7.4.240.0040.00316.52
7.4.230.0070.00016.31
7.4.220.0030.00516.73
7.4.210.0070.01116.52
7.4.200.0000.00716.61
7.4.160.0150.00616.51
7.4.140.0110.01317.86
7.4.130.0100.01416.50
7.4.120.0090.01216.50
7.4.110.0100.00716.67
7.4.100.0130.00316.57
7.4.90.0160.00616.50
7.4.80.0000.01719.39
7.4.70.0030.01316.55
7.4.60.0120.00416.45
7.4.50.0070.01016.34
7.4.40.0070.01316.66
7.4.00.0060.00915.13
7.3.330.0000.00513.25
7.3.320.0030.00313.18
7.3.310.0040.00416.35
7.3.300.0030.00316.28
7.3.290.0000.00816.30
7.3.280.0060.00916.31
7.3.260.0110.01216.54
7.3.240.0070.01016.43
7.3.230.0030.01316.66
7.3.210.0070.01016.57
7.3.200.0120.00316.70
7.3.190.0080.01516.57
7.3.180.0000.01816.33
7.3.170.0100.00716.66
7.3.160.0120.00416.60
7.3.30.0060.01114.87
7.3.20.1650.00314.77
7.3.10.1460.00514.97
7.3.00.1460.00314.87
7.2.330.0090.00916.80
7.2.320.0160.00316.90
7.2.310.0080.00816.71
7.2.300.0080.00816.79
7.2.290.0130.01016.71
7.2.160.0070.00914.79
7.2.150.1820.00715.10
7.2.140.1370.00815.18
7.2.130.1220.01015.15
7.2.120.1390.01015.19
7.2.110.1350.00714.90
7.2.100.1450.00715.06
7.2.90.1590.00515.15
7.2.80.1960.01015.05
7.2.70.1830.00815.17
7.2.60.1520.00715.26
7.2.50.1740.00515.00
7.2.40.1540.00515.10
7.2.30.1530.00715.14
7.2.20.1610.00514.95
7.2.10.1480.00715.15
7.2.00.1640.00815.18
7.1.270.1420.00813.89
7.1.260.1380.00213.86
7.1.250.1500.00214.05

preferences:
33.84 ms | 400 KiB | 5 Q