3v4l.org

run code in 300+ PHP versions simultaneously
<?php $allowedweapons = ['Scissors', 'Paper', 'Rock', 'Lizard', 'Spock']; $rules = [ 'scissorspaper' => 'cuts', 'paperrock' => 'covers', 'rocklizard' => 'crushes', 'lizardspock' => 'poisons', 'spockscissors' => 'smashes', 'scissorslizard' => 'decapitates', 'lizardpaper' => 'eats', 'paperspock' => 'disproves', 'spockrock' => 'vaporizes', 'rockscissors' => 'crushes' ]; class Game { protected $rules; public function __construct($rules) { $this->rules = $rules; } public function run($weaponP1, $weaponP2) { if ($weaponP1 === $weaponP2) { echo "It is a tie"; return; } $result = $this->checkVerbs($weaponP1, $weaponP2); $winner = 'Player 1'; if (!$result) { $result = $this->checkVerbs($weaponP2, $weaponP1); $winner = 'Player 2'; } echo "The winner is: $winner\n"; echo "Because of: " . $result; } /** * @param $weaponP1 * @param $weaponP2 * @return bool|string */ protected function checkVerbs($weaponP1, $weaponP2) { $key = strtolower($weaponP1 . $weaponP2); if (!array_key_exists($key, $this->rules)) { return false; } return $weaponP1 . ' ' . $this->rules[$key] . ' ' . $weaponP2; } } (new Game($rules))->run('Scissors', 'Paper');

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.0110.00416.49
8.3.50.0090.00918.43
8.3.40.0060.01018.73
8.3.30.0110.00418.79
8.3.20.0090.00620.29
8.3.10.0080.00023.36
8.3.00.0030.00519.91
8.2.180.0120.00318.29
8.2.170.0140.00722.96
8.2.160.0110.00420.45
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0000.00821.06
8.2.120.0080.00026.35
8.2.110.0090.00020.44
8.2.100.0030.00917.93
8.2.90.0050.00319.01
8.2.80.0030.00517.97
8.2.70.0030.00617.75
8.2.60.0030.00517.93
8.2.50.0080.00018.07
8.2.40.0030.00521.12
8.2.30.0000.00820.52
8.2.20.0000.00817.75
8.2.10.0000.00718.09
8.2.00.0000.00818.20
8.1.280.0070.01125.92
8.1.270.0040.00420.34
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0060.00322.19
8.1.230.0080.00317.79
8.1.220.0000.00917.74
8.1.210.0030.00618.77
8.1.200.0000.00917.47
8.1.190.0030.00617.22
8.1.180.0060.00318.10
8.1.170.0000.00818.46
8.1.160.0040.00420.68
8.1.150.0000.00718.97
8.1.140.0040.00419.47
8.1.130.0030.00317.81
8.1.120.0080.00017.52
8.1.110.0000.00717.48
8.1.100.0000.00717.54
8.1.90.0040.00417.42
8.1.80.0000.00817.43
8.1.70.0030.00317.43
8.1.60.0070.00017.59
8.1.50.0040.00417.58
8.1.40.0040.00417.47
8.1.30.0040.00417.66
8.1.20.0040.00417.62
8.1.10.0040.00417.50
8.1.00.0090.00317.53
8.0.300.0070.00318.77
8.0.290.0040.00416.75
8.0.280.0000.00718.37
8.0.270.0000.00717.13
8.0.260.0040.00417.34
8.0.250.0030.00316.88
8.0.240.0000.00816.87
8.0.230.0030.00617.02
8.0.220.0080.00016.80
8.0.210.0030.00316.92
8.0.200.0060.00017.01
8.0.190.0030.00616.86
8.0.180.0040.00416.82
8.0.170.0040.00416.94
8.0.160.0000.00716.93
8.0.150.0080.00016.84
8.0.140.0040.00416.79
8.0.130.0000.00813.30
8.0.120.0000.00816.88
8.0.110.0040.00416.96
8.0.100.0000.00716.93
8.0.90.0080.00016.86
8.0.80.0110.00516.95
8.0.70.0030.00616.71
8.0.60.0000.00816.88
8.0.50.0030.00316.77
8.0.30.0070.00817.04
8.0.20.0130.00917.40
8.0.10.0050.00316.86
8.0.00.0140.00316.78
7.4.330.0000.00616.84
7.4.320.0000.00716.48
7.4.300.0000.00616.44
7.4.290.0000.00716.67
7.4.280.0000.00716.61
7.4.270.0080.00016.54
7.4.260.0000.00716.65
7.4.250.0040.00416.51
7.4.240.0000.00716.61
7.4.230.0070.00016.70
7.4.220.0070.01416.50
7.4.210.0060.01216.60
7.4.200.0030.00316.51
7.4.160.0140.00716.57
7.4.150.0140.01117.40
7.4.140.0170.00717.86
7.4.130.0100.00816.53
7.4.120.0090.00816.56
7.4.110.0100.01116.44
7.4.100.0060.01616.46
7.4.90.0110.00716.71
7.4.80.0100.00719.39
7.4.70.0070.01016.43
7.4.60.0080.00816.56
7.4.50.0090.00616.20
7.4.40.0070.01016.67
7.4.30.0000.01716.43
7.4.00.0060.01214.93
7.3.330.0060.00013.24
7.3.320.0040.00413.45
7.3.310.0000.00716.41
7.3.300.0000.00616.25
7.3.290.0080.00816.35
7.3.280.0120.00816.38
7.3.270.0120.00617.40
7.3.260.0140.00516.69
7.3.250.0100.01116.42
7.3.240.0110.00616.53
7.3.230.0140.00416.63
7.3.210.0130.00316.29
7.3.200.0120.00916.56
7.3.190.0070.01016.35
7.3.180.0040.01216.59
7.3.170.0170.00016.46
7.3.160.0080.00816.66
7.3.120.0090.00914.87
7.3.110.0060.01114.95
7.3.100.0100.00514.68
7.3.90.0030.01014.60
7.3.80.0070.00514.86
7.3.70.0090.00614.76
7.3.60.0050.01214.95
7.3.50.0080.00714.76
7.3.40.0030.00814.70
7.3.30.0040.01015.00
7.3.20.0030.01016.65
7.3.10.0090.00516.57
7.3.00.0080.00316.70
7.2.330.0090.00916.73
7.2.320.0060.01416.86
7.2.310.0050.01116.52
7.2.300.0070.01016.86
7.2.290.0100.00616.80
7.2.250.0110.00915.19
7.2.240.0030.01715.22
7.2.230.0070.00515.13
7.2.220.0050.00715.24
7.2.210.0080.00715.17
7.2.200.0050.01015.21
7.2.190.0090.00615.15
7.2.180.0060.00815.15
7.2.170.0050.00815.07
7.2.00.0070.01119.53
7.1.330.0070.00915.74
7.1.320.0100.00315.82
7.1.310.0050.00615.94
7.1.300.0080.00715.81
7.1.290.0050.00715.80
7.1.280.0050.00815.79
7.1.270.0040.00915.61
7.1.260.0040.01015.66
7.1.100.0030.01518.31
7.1.70.0000.01017.09
7.1.60.0070.01119.13
7.1.50.0100.01316.88
7.1.00.0000.07722.40
7.0.200.0000.00816.63
7.0.60.0070.05720.05
7.0.50.0030.08717.89
7.0.40.0170.07319.96
7.0.30.0230.08020.33
7.0.20.0270.04020.22
7.0.10.0070.08720.12
7.0.00.0070.09020.30
5.6.280.0000.05021.09
5.6.210.0130.07720.68
5.6.200.0100.08318.16
5.6.190.0030.04720.64
5.6.180.0000.04320.77
5.6.170.0170.04320.52
5.6.160.0070.04020.57
5.6.150.0030.09018.21
5.6.140.0130.06318.26
5.6.130.0130.06318.25
5.6.120.0000.06721.13
5.6.110.0130.07021.02
5.6.100.0030.04021.12
5.6.90.0070.06021.02
5.6.80.0100.07020.54
5.5.350.3700.02720.41
5.5.340.0000.04018.09
5.5.330.0130.07720.19
5.5.320.0370.08020.36
5.5.310.0170.08720.32
5.5.300.0100.07718.08
5.5.290.0030.08718.07
5.5.280.0030.08720.88
5.5.270.0100.08720.80
5.5.260.0070.08020.88
5.5.250.0070.08720.69
5.5.240.0170.08020.16

preferences:
57.62 ms | 401 KiB | 5 Q