3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Card { protected $suit; protected $value; protected $suit_text; protected $value_text; protected $facedown = false; public function __construct($suit, $value) { $suits = array( 'H' => 'Hearts', 'C' => 'Clubs', 'D' => 'Diamonds', 'S' => 'Spades' ); $values = array( 'A' => 'Ace', '2' => 'Two', '3' => 'Three', '4' => 'Four', '5' => 'Five', '6' => 'Six', '7' => 'Seven', '8' => 'Eight', '9' => 'Nine', '10' => 'Ten', 'J' => 'Jack', 'Q' => 'Queen', 'K' => 'King' ); $this->suit = $suit; $this->value = $value; $this->suit_text = $suits[$suit]; $this->value_text = $values[$value]; } /** * @return string */ public function getSuit() { return $this->suit; } /** * @return string */ public function getValue() { return $this->value; } /** * @return string */ public function getAsText() { return $this->value_text.' of '.$this->suit_text; } /** * @return string */ public function getSuitAsText() { return $this->suit_text; } /** * @return string */ public function getValueAsText() { return $this->value_text; } /** * Generates HTML for the card * @param string $id * @return string */ public function getHtml($id = null) { $html = '<div id="'.$id.'" class="playing-card card-' .strtolower($this->getValue()) .strtolower($this->getSuit()).' '; if($this->facedown == true){$html .= 'playing-card-facedown ';} $html .= '"></div>'; return $html; } /** * @return string */ public function getJson() { $class = 'playing-card card-'.strtolower($this->getValue()).strtolower($this->getSuit()).' '; if($this->facedown == true){$class .= 'playing-card-facedown ';} $array = array( 'suit' => $this->getSuit(), 'value' => $this->getValue(), 'suit_text' => $this->getSuitAsText(), 'value_text' => $this->getValueAsText(), 'facedown' => $this->facedown, 'divclass' => $class ); return json_encode($array); } /** * Flips the card face up or face down */ public function flipCard() { if($this->facedown == false) { $this->facedown = true; } else { $this->facedown = false; } } /** * Flips the card face down */ public function flipFaceDown() { $this->facedown = true; } /** * Flips the card face up */ public function flipFaceUp() { $this->facedown = false; } /** * @return bool */ public function isFaceDown() { if($this->facedown == true) { return true; } return false; } } $cards = []; $hand = 'As Ks Qs Js 10s'; $array = explode(' ', $hand); foreach ($array as $card) { $val = substr($card, 0, -1); $suit = strtoupper(substr($card, -1)); $cards[] = new Card($suit, $val); } var_dump($cards);

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.0120.00618.55
8.3.50.0140.00617.36
8.3.40.0180.00018.73
8.3.30.0120.00318.84
8.3.20.0040.00421.94
8.3.10.0040.00421.90
8.3.00.0080.00021.92
8.2.180.0150.00016.75
8.2.170.0070.01522.96
8.2.160.0060.00920.44
8.2.150.0030.00624.18
8.2.140.0090.00024.66
8.2.130.0030.00619.95
8.2.120.0040.00426.35
8.2.110.0070.00419.38
8.2.100.0120.00317.91
8.2.90.0050.00318.34
8.2.80.0060.00317.97
8.2.70.0000.00917.93
8.2.60.0030.00518.21
8.2.50.0040.00418.10
8.2.40.0060.00319.30
8.2.30.0000.00920.63
8.2.20.0030.00618.25
8.2.10.0040.00419.50
8.2.00.0040.00418.20
8.1.280.0170.00325.92
8.1.270.0090.00020.27
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0000.01022.45
8.1.230.0090.00321.10
8.1.220.0080.00017.79
8.1.210.0000.00819.00
8.1.200.0030.00517.61
8.1.190.0040.00417.13
8.1.180.0060.00318.10
8.1.170.0030.00518.70
8.1.160.0000.00719.01
8.1.150.0000.00818.96
8.1.140.0040.00419.09
8.1.130.0080.00017.52
8.1.120.0050.00317.43
8.1.110.0040.00417.58
8.1.100.0050.00317.43
8.1.90.0000.00817.54
8.1.80.0040.00417.45
8.1.70.0000.00917.58
8.1.60.0000.00917.61
8.1.50.0040.00417.51
8.1.40.0040.00417.62
8.1.30.0000.00817.71
8.1.20.0030.00617.75
8.1.10.0040.00417.65
8.1.00.0060.00317.44
8.0.300.0030.00620.21
8.0.290.0040.00416.88
8.0.280.0000.00718.47
8.0.270.0000.00817.27
8.0.260.0000.00716.89
8.0.250.0030.00316.92
8.0.240.0040.00417.05
8.0.230.0080.00016.99
8.0.220.0000.00916.96
8.0.210.0000.00716.96
8.0.200.0030.00317.05
8.0.190.0000.00817.02
8.0.180.0040.00416.85
8.0.170.0040.00417.02
8.0.160.0040.00416.96
8.0.150.0040.00416.88
8.0.140.0040.00416.81
8.0.130.0030.00313.36
8.0.120.0000.00816.84
8.0.110.0040.00416.97
8.0.100.0000.00817.07
8.0.90.0080.00017.04
8.0.80.0120.00616.95
8.0.70.0030.00616.88
8.0.60.0040.00417.08
8.0.50.0000.00716.81
8.0.30.0110.01117.08
8.0.20.0100.01216.84
8.0.10.0030.00617.13
8.0.00.0110.01016.78
7.4.330.0000.00516.77
7.4.320.0000.00716.58
7.4.300.0040.00416.52
7.4.290.0000.00716.67
7.4.280.0030.00616.65
7.4.270.0090.00016.57
7.4.260.0000.00816.42
7.4.250.0080.00016.46
7.4.240.0040.00416.67
7.4.230.0020.00516.74
7.4.220.0040.00416.66
7.4.210.0120.00616.58
7.4.200.0080.00016.70
7.4.140.0090.00917.86
7.4.130.0110.00716.46
7.4.120.0090.01216.56
7.4.110.0090.01516.55
7.4.100.0090.01316.73
7.4.90.0160.00316.57
7.4.80.0090.01319.39
7.4.70.0120.00916.66
7.4.60.0160.00016.40
7.4.50.0040.01416.46
7.4.40.0150.00916.56
7.4.10.0100.01015.14
7.4.00.0040.01314.87
7.3.330.0030.00313.42
7.3.320.0000.00613.36
7.3.310.0050.00316.36
7.3.300.0040.00416.33
7.3.290.0030.00316.39
7.3.280.0050.01316.38
7.3.260.0120.01116.53
7.3.240.0120.00816.45
7.3.230.0140.00616.70
7.3.210.0140.00716.71
7.3.200.0110.00716.50
7.3.190.0100.01316.43
7.3.180.0120.00416.35
7.3.170.0070.01016.55
7.3.160.0080.01016.59
7.3.130.0150.00614.95
7.3.120.0080.00915.01
7.3.110.0060.01114.87
7.3.100.0060.00815.01
7.3.90.0100.00614.93
7.3.80.0060.00914.91
7.3.70.0050.01114.73
7.3.60.0060.00814.92
7.3.50.0060.01014.77
7.3.40.0070.00714.92
7.3.30.0080.00814.89
7.3.20.0070.00716.56
7.3.10.0060.01016.62
7.3.00.0070.00716.74
7.2.330.0100.01016.57
7.2.320.0090.01216.68
7.2.310.0140.00316.69
7.2.300.0120.00416.57
7.2.290.0060.01116.56
7.2.260.0080.01214.69
7.2.250.0040.01615.24
7.2.240.0050.01015.02
7.2.230.0040.01115.26
7.2.220.0070.00514.99
7.2.210.0030.01015.13
7.2.200.0070.00915.10
7.2.190.0070.00615.08
7.2.180.0080.00815.07
7.2.170.0100.00515.04
7.2.160.0070.00715.03
7.2.150.0070.00916.88
7.2.140.0090.00616.86
7.2.130.0060.00816.92
7.2.120.0090.00816.94
7.2.110.0080.00616.92
7.2.100.0050.00816.89
7.2.90.0060.01016.97
7.2.80.0060.00816.99
7.2.70.0050.01016.84
7.2.60.0040.01116.90
7.2.50.0060.01216.98
7.2.40.0060.00817.01
7.2.30.0080.00817.00
7.2.20.0070.00916.96
7.2.10.0080.00616.89
7.2.00.0090.00616.92
7.1.330.0080.00715.92
7.1.320.0060.00715.78
7.1.310.0060.00815.77
7.1.300.0060.00915.79
7.1.290.0090.00815.80
7.1.280.0090.00615.67
7.1.270.0060.00615.74
7.1.260.0060.00815.78
7.1.250.0070.00615.84
7.1.240.0030.01215.75
7.1.230.0060.00615.66
7.1.220.0040.00815.88
7.1.210.0030.01015.89
7.1.200.0040.01115.86
7.1.190.0040.01115.66
7.1.180.0090.00315.70
7.1.170.0060.00915.70
7.1.160.0000.01215.61
7.1.150.0040.01115.64
7.1.140.0060.00915.98
7.1.130.0070.00415.79
7.1.120.0070.00715.63
7.1.110.0040.01115.96
7.1.100.0040.01415.89
7.1.90.0100.00315.71
7.1.80.0070.00415.72
7.1.70.0030.00915.88
7.1.60.0080.00016.03
7.1.50.0090.00315.70
7.1.40.0030.01015.98
7.1.30.0030.01415.65
7.1.20.0040.01115.76
7.1.10.0120.00315.77
7.1.00.0100.00315.62

preferences:
67.81 ms | 401 KiB | 5 Q