3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ClientController { function __construct($clients) { foreach ($clients as $key => $value) { $clients[$key]['name_valid'] = $this->validName($value['name']); $clients[$key]['cpf_valid'] = $this->validCpf($value['cpf']); $clients[$key]['birth_date_valid'] = $this->validBirthdate($value['birth_date']); $clients[$key]['email_valid'] = $this->validEmail($value['email']); } print_r($clients); } function validName($name) { return (!empty($name) && !preg_match("/^[a-zA-Z'-]+$/", $name)); } function validCpf($cpf) { return (!empty($cpf) && ctype_digit($cpf)); } function validBirthdate($date) { return (!empty($birthdate) && preg_match("/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/", $birthdate)); } function validEmail($email) { return (filter_var($email, FILTER_VALIDATE_EMAIL)); } } class ClientModel { private $name; private $cpf; private $birth_date; private $email; public function __construct($name, $cpf, $birth_date, $email) { $this->setName($name); $this->setCpf($cpf); $this->setBirthDate($birth_date); $this->setEmail($email); } public function getName() { return $this->name; } public function setName($name) { $this->name = $name; } public function getCpf() { return $this->cpf; } public function setCpf($cpf) { $this->cpf = $cpf; } public function getBirthDate() { return $this->birth_date; } public function setBirthDate($birth_date) { $this->birth_date = $birth_date; } public function getEmail() { return $this->email; } public function setEmail($email) { $this->email = $email; } } class ClientCollection { private $_clients = []; public function add(ClientModel $client) { $this->_clients[] = $client; end($this->_clients); return key($this->_clients); } public function get($key) { if (isset($this->_clients[$key])) { return $this->_clients[$key]; } else { throw new Exception("Client does not exist"); } } public function delete($key) { if (isset($this->_clients[$key])) { unset($this->_clients[$key]); } else { throw new Exception("Client does not exist"); } } } $clients = array( array("name" => "Hubert Adams", "cpf" => "86383860011", "birth_date" => "20/07/2015", "email" => "carlee_fadel@block.name"), array("name" => "Isabelle Mann", "cpf" => "58958058684", "birth_date" => "27/07/2015", "email" => "dortha.pacocha@ebert.biz"), array("name" => "Jayda Reichert", "cpf" => "01075384664", "birth_date" => "24/07/2015", "email" => "kaylie@stehrgaylord.biz"), array("name" => "Brionna Reinger", "cpf" => "48991299636", "birth_date" => "22/07/2015", "email" => "ansley.orn@herzog.org"), array("name" => "Diego", "cpf" => "55483741684aaaa", "birth_date" => "", "email" => "raoul mills com") ); $collection = new ClientCollection(); foreach ($clients as $client) { $model = new ClientModel($client['name'], $client['cpf'], $client['birth_date'], $client['email']); $collection->add($model); } var_dump($collection);

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.0090.00918.43
8.3.50.0250.01021.17
8.3.40.0070.00718.87
8.3.30.0110.00319.16
8.3.20.0050.00320.29
8.3.10.0040.00421.76
8.3.00.0030.00519.25
8.2.180.0190.00018.05
8.2.170.0090.00619.07
8.2.160.0090.01222.96
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0000.00721.00
8.2.110.0060.00319.36
8.2.100.0130.00017.75
8.2.90.0030.00619.35
8.2.80.0030.00617.97
8.2.70.0000.00817.63
8.2.60.0050.00318.05
8.2.50.0060.00318.07
8.2.40.0030.00518.16
8.2.30.0080.00018.30
8.2.20.0080.00017.73
8.2.10.0020.00518.19
8.2.00.0030.00518.06
8.1.280.0070.01025.92
8.1.270.0130.00620.38
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00022.65
8.1.230.0040.00817.83
8.1.220.0040.00417.78
8.1.210.0050.00318.77
8.1.200.0070.00317.48
8.1.190.0050.00317.35
8.1.180.0050.00318.10
8.1.170.0040.00418.75
8.1.160.0000.00822.00
8.1.150.0060.00318.95
8.1.140.0040.00717.57
8.1.130.0000.00717.77
8.1.120.0040.00417.52
8.1.110.0070.00017.57
8.1.100.0040.00417.52
8.1.90.0050.00317.48
8.1.80.0000.00817.52
8.1.70.0040.00417.56
8.1.60.0060.00317.63
8.1.50.0040.00417.64
8.1.40.0080.00017.54
8.1.30.0060.00317.77
8.1.20.0040.00417.73
8.1.10.0000.00917.63
8.1.00.0050.00317.60
8.0.300.0000.00818.77
8.0.290.0030.00616.88
8.0.280.0030.00518.42
8.0.270.0000.00717.25
8.0.260.0030.00317.38
8.0.250.0000.00717.11
8.0.240.0040.00416.96
8.0.230.0000.00716.97
8.0.220.0030.00316.98
8.0.210.0070.00017.04
8.0.200.0030.00317.09
8.0.190.0040.00417.07
8.0.180.0040.00416.93
8.0.170.0040.00417.01
8.0.160.0030.00516.91
8.0.150.0050.00316.95
8.0.140.0070.00017.03
8.0.130.0000.00813.41
8.0.120.0000.00817.03
8.0.110.0080.00016.98
8.0.100.0030.00517.09
8.0.90.0050.00217.01
8.0.80.0030.01317.02
8.0.70.0050.00316.92
8.0.60.0030.00516.90
8.0.50.0030.00517.07
8.0.30.0070.01517.13
8.0.20.0150.00617.40
8.0.10.0040.00416.98
8.0.00.0120.01016.67
7.4.330.0030.00315.15
7.4.320.0030.00316.67
7.4.300.0030.00316.68
7.4.290.0040.00416.67
7.4.280.0000.00916.64
7.4.270.0030.00316.69
7.4.260.0000.00716.56
7.4.250.0040.00416.45
7.4.240.0020.00516.64
7.4.230.0040.00416.77
7.4.220.0030.01516.74
7.4.210.0060.01316.53
7.4.200.0000.00716.55
7.4.160.0080.00816.64
7.4.150.0120.00617.40
7.4.140.0110.00917.86
7.4.130.0110.01016.54
7.4.120.0080.01216.68
7.4.110.0060.01316.39
7.4.100.0160.00416.43
7.4.90.0150.00616.61
7.4.80.0130.00619.39
7.4.70.0150.00916.75
7.4.60.0100.00616.45
7.4.50.0030.00616.32
7.4.40.0210.00316.56
7.4.30.0190.00316.69
7.4.00.0090.00914.86
7.3.330.0000.00513.30
7.3.320.0030.00313.28
7.3.310.0040.00416.34
7.3.300.0070.00016.45
7.3.290.0100.00816.49
7.3.280.0100.00916.42
7.3.270.0000.01817.40
7.3.260.0100.00716.80
7.3.250.0090.01016.54
7.3.240.0060.01216.63
7.3.230.0060.01316.48
7.3.210.0090.00916.35
7.3.200.0120.00419.39
7.3.190.0130.00316.45
7.3.180.0090.00916.35
7.3.170.0160.00016.45
7.3.160.0030.01716.69
7.3.120.0060.01214.84
7.3.110.0050.00814.98
7.3.100.0080.00414.80
7.3.90.0030.00814.89
7.3.80.0040.01114.87
7.3.70.0060.00914.88
7.3.60.0000.01515.04
7.3.50.0050.00515.09
7.3.40.0000.01814.94
7.3.30.0090.00314.96
7.3.20.0070.01016.63
7.3.10.0100.01016.52
7.3.00.0060.01016.77
7.2.330.0090.01216.45
7.2.320.0090.00916.48
7.2.310.0030.01416.52
7.2.300.0030.01616.76
7.2.290.0120.00916.70
7.2.250.0020.01615.23
7.2.240.0090.01215.00
7.2.230.0030.01415.33
7.2.220.0040.01515.18
7.2.210.0140.00414.95
7.2.200.0070.01015.21
7.2.190.0140.00415.09
7.2.180.0000.01414.97
7.2.170.0040.01115.07
7.2.60.0000.01016.84
7.2.00.0130.00319.23
7.1.330.0040.01115.94
7.1.320.0100.00315.93
7.1.310.0030.00915.73
7.1.300.0000.01615.81
7.1.290.0090.00615.72
7.1.280.0060.00915.70
7.1.270.0070.01015.76
7.1.260.0090.00615.60
7.1.200.0110.00315.93
7.1.100.0030.01018.06
7.1.70.0090.00616.93
7.1.60.0070.01119.59
7.1.50.0090.01216.79
7.1.00.0030.07722.47
7.0.200.0050.00316.89
7.0.60.0200.08021.73
7.0.50.0100.03717.88
7.0.40.0200.04020.11
7.0.30.0300.08020.18
7.0.20.0330.07020.24
7.0.10.0070.04020.08
7.0.00.0170.07020.23
5.6.210.0070.08320.59
5.6.200.0070.04018.20
5.6.190.0070.04320.57
5.6.180.0330.08020.48
5.6.170.0330.07720.54
5.6.160.0030.05720.54
5.6.150.0030.04318.23
5.6.140.0000.05318.15
5.6.130.0100.03718.21
5.6.120.0100.06721.08
5.6.110.0100.07721.14
5.6.100.0130.07721.04
5.6.90.0130.08021.00
5.6.80.0000.04020.41
5.5.350.0300.07320.50
5.5.340.0130.08017.94
5.5.330.0070.08320.39
5.5.320.0200.05020.36
5.5.310.0130.05020.51
5.5.300.0030.05317.96
5.5.290.0100.07017.98
5.5.280.0100.08720.71
5.5.270.0070.08720.71
5.5.260.0100.05320.98
5.5.250.0100.04320.53
5.5.240.0370.06020.27
5.4.450.3530.03319.55
5.4.440.0070.07719.42
5.4.430.1800.05019.36
5.4.420.4270.03319.27
5.4.410.4770.03719.45
5.4.400.2730.04319.16
5.4.390.2830.03319.17
5.4.380.3530.03719.07
5.4.370.2330.03019.04
5.4.360.2900.03719.15
5.4.350.2500.03319.11
5.4.340.4000.04018.95
5.4.320.4270.04019.15
5.4.310.4200.04019.17
5.4.300.4270.04318.93
5.4.290.4470.04719.04
5.4.280.0100.07719.13
5.4.270.0530.06319.22
5.4.260.4230.04018.96
5.4.250.3730.03719.13
5.4.240.3600.04318.94
5.4.230.3930.03319.12
5.4.220.4400.03719.21
5.4.210.4100.04319.10
5.4.200.3800.03719.22
5.4.190.4530.03718.92
5.4.180.0100.07019.21
5.4.170.3330.04019.09
5.4.160.4270.03318.93
5.4.150.4670.03719.24
5.4.140.3900.03016.42
5.4.130.3770.03316.50
5.4.120.4230.04316.45
5.4.110.4270.03716.53
5.4.100.3570.03316.57
5.4.90.4800.04316.68
5.4.80.3700.03316.25
5.4.70.3200.04016.49
5.4.60.4470.03316.33
5.4.50.4270.03716.50
5.4.40.4070.03316.43
5.4.30.4200.03716.48
5.4.20.3970.03316.35
5.4.10.3500.04016.50
5.4.00.4130.03715.89
5.3.290.4730.03314.74
5.3.280.4130.04314.70
5.3.270.0030.04314.64
5.3.260.4800.03314.52
5.3.250.4470.03314.63
5.3.240.3830.04014.79
5.3.230.3930.03014.68
5.3.220.3500.03714.61
5.3.210.3200.03314.63
5.3.200.3170.03314.65
5.3.190.4430.04314.63
5.3.180.4070.04314.67
5.3.170.4900.04714.59
5.3.160.4370.03314.60
5.3.150.4130.04014.67
5.3.140.4230.03014.75
5.3.130.4830.04714.58
5.3.120.3900.04014.58
5.3.110.3930.04014.63
5.3.100.3770.03714.14
5.3.90.3770.03014.06
5.3.80.4100.03313.97
5.3.70.4370.03714.09
5.3.60.4430.04014.11
5.3.50.4430.03313.89
5.3.40.4670.04014.00
5.3.30.4370.04013.97
5.3.20.4200.03713.86
5.3.10.4270.04013.84
5.3.00.4400.02713.63
5.2.170.3970.03311.23
5.2.160.3800.03011.21
5.2.150.3630.02711.14
5.2.140.3700.02311.21
5.2.130.3630.02711.29
5.2.120.3530.02311.15
5.2.110.3800.03011.19
5.2.100.2470.03011.11
5.2.90.2970.02311.15
5.2.80.3130.03011.05
5.2.70.3670.02311.04
5.2.60.3870.03711.04
5.2.50.3730.03311.09
5.2.40.3200.03311.08
5.2.30.3000.03011.05
5.2.20.2630.02711.01
5.2.10.2430.03010.79
5.2.00.2670.03010.75
5.1.60.2300.02310.18
5.1.50.0370.02710.03
5.1.40.0830.02010.04
5.1.30.2170.02310.42
5.1.20.2000.02310.39
5.1.10.1800.02710.13
5.1.00.2300.02310.16
5.0.50.1200.0238.64
5.0.40.0570.0138.52
5.0.30.0930.0338.30
5.0.20.1370.0238.15
5.0.10.0230.0178.28
5.0.00.0400.0308.22
4.4.90.1230.0135.96
4.4.80.1730.0175.87
4.4.70.1270.0205.89
4.4.60.1730.0105.81
4.4.50.1430.0205.89
4.4.40.0700.0275.88
4.4.30.0200.0135.87
4.4.20.0600.0175.93
4.4.10.1030.0175.93
4.4.00.1130.0235.91
4.3.110.0630.0105.82
4.3.100.0900.0175.80
4.3.90.0830.0135.79
4.3.80.1100.0275.74
4.3.70.1270.0105.73
4.3.60.1230.0135.82
4.3.50.0470.0175.70
4.3.40.0930.0205.75
4.3.30.0370.0175.54
4.3.20.0530.0175.54
4.3.10.0600.0175.54
4.3.00.0600.0175.54

preferences:
53.27 ms | 401 KiB | 5 Q