3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class DateValidator { const DATE_FORMAT = 'd/m/Y'; // DD/MM/YYYY const DATE_EXP = '/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/'; public static function validateHistoricalDate(string $dateString): HistoricalDate { $historicalDate = new HistoricalDate($dateString); $date = DateTime::createFromFormat(self::DATE_FORMAT, $dateString); if (!$date || !preg_match(self::DATE_EXP, $dateString, $dateParts)) { $historicalDate->setMessage('Date is not in the required format DD/MM/YYYY [PHP - d/m/Y]'); return $historicalDate; } if (!checkdate((int) $dateParts[2], (int) $dateParts[1], (int) $dateParts[3])) { $historicalDate->setMessage('Date is not valid'); return $historicalDate; } if ($date > new DateTime()) { $historicalDate->setMessage('Date is not historical'); return $historicalDate; } $historicalDate->setValidity(true); return $historicalDate; } } class HistoricalDate { private $date; private $valid = false; private $message = ''; public function __construct(string $date) { $this->setDate($date); } public function setValidity(bool $value) { $this->valid = $value; } public function setMessage(string $message) { $this->message = $message; } public function isValid(): bool { return $this->valid; } public function getMessage(): string { return $this->message; } public function getDate(): string { return $this->date; } private function setDate(string $date) { $this->date = $date; } } $dateString = "xxxxx10/02/2017"; $result = DateValidator::validateHistoricalDate($dateString); if (!$result->isValid()) { $message = $result->getMessage(); } echo $result->isValid() ? 'Valid date' : $message;

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.0070.00718.55
8.3.50.0030.01718.26
8.3.40.0140.00418.83
8.3.30.0120.00318.88
8.3.20.0000.00821.73
8.3.10.0040.00420.39
8.3.00.0040.00419.91
8.2.180.0110.00718.25
8.2.170.0040.01122.96
8.2.160.0040.01122.19
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0050.00226.16
8.2.120.0120.00621.13
8.2.110.0030.00621.12
8.2.100.0040.00818.03
8.2.90.0060.00319.27
8.2.80.0000.00917.97
8.2.70.0000.01317.38
8.2.60.0000.00817.93
8.2.50.0050.00318.10
8.2.40.0000.00820.36
8.2.30.0040.00419.13
8.2.20.0030.00618.18
8.2.10.0050.00218.12
8.2.00.0030.00517.79
8.1.280.0100.00725.92
8.1.270.0040.00422.15
8.1.260.0030.00726.35
8.1.250.0080.00028.09
8.1.240.0090.00022.74
8.1.230.0040.00817.45
8.1.220.0060.00317.74
8.1.210.0030.00518.77
8.1.200.0000.01017.48
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0050.00318.47
8.1.160.0000.00718.89
8.1.150.0070.00022.05
8.1.140.0040.00419.61
8.1.130.0070.00019.13
8.1.120.0070.00017.51
8.1.110.0040.00417.48
8.1.100.0000.00717.50
8.1.90.0000.00717.41
8.1.80.0070.00017.42
8.1.70.0040.00417.59
8.1.60.0030.00617.58
8.1.50.0030.00617.53
8.1.40.0000.00817.49
8.1.30.0000.00817.69
8.1.20.0040.00417.48
8.1.10.0030.00517.58
8.1.00.0040.00417.49
8.0.300.0000.00718.77
8.0.290.0090.00016.88
8.0.280.0030.00318.45
8.0.270.0000.00717.18
8.0.260.0030.00317.18
8.0.250.0000.00717.00
8.0.240.0070.00017.14
8.0.230.0040.00417.05
8.0.220.0070.00016.98
8.0.210.0070.00017.00
8.0.200.0000.00617.09
8.0.190.0040.00417.02
8.0.180.0040.00416.94
8.0.170.0000.00717.08
8.0.160.0000.00817.04
8.0.150.0050.00216.94
8.0.140.0020.00516.89
8.0.130.0060.00013.46
8.0.120.0000.00717.00
8.0.110.0030.00316.92
8.0.100.0000.00716.87
8.0.90.0000.00717.10
8.0.80.0150.00617.00
8.0.70.0040.00316.86
8.0.60.0040.00416.86
8.0.50.0040.00416.86
8.0.30.0090.00917.31
8.0.20.0130.00817.42
8.0.10.0030.00617.11
8.0.00.0100.00716.92
7.4.330.0000.00615.55
7.4.320.0000.00716.63
7.4.300.0030.00316.48
7.4.290.0080.00016.53
7.4.280.0050.00316.51
7.4.270.0000.00716.60
7.4.260.0070.00316.54
7.4.250.0030.00316.60
7.4.240.0040.00416.61
7.4.230.0030.00316.72
7.4.220.0100.00716.54
7.4.210.0070.01016.56
7.4.200.0050.00216.31
7.4.160.0060.01016.57
7.4.150.0030.01917.40
7.4.140.0090.00817.86
7.4.130.0090.00816.59
7.4.120.0130.00816.60
7.4.110.0070.01016.28
7.4.100.0180.00316.50
7.4.90.0150.00616.57
7.4.80.0090.00919.39
7.4.70.0120.00616.72
7.4.60.0070.01016.57
7.4.50.0070.01016.50
7.4.40.0030.01416.71
7.4.30.0120.00616.61
7.4.00.0050.01214.76
7.3.330.0050.00013.16
7.3.320.0030.00313.43
7.3.310.0050.00216.40
7.3.300.0030.00316.39
7.3.290.0060.00816.37
7.3.280.0100.00916.35
7.3.270.0090.00817.40
7.3.260.0080.01116.36
7.3.250.0120.00716.48
7.3.240.0060.01116.50
7.3.230.0060.01216.56
7.3.210.0060.00916.50
7.3.200.0150.00516.18
7.3.190.0090.00616.56
7.3.180.0080.00816.62
7.3.170.0110.00616.55
7.3.160.0090.00616.46
7.3.120.0060.01014.99
7.3.110.0090.00915.02
7.3.100.0030.01014.93
7.3.90.0060.00614.82
7.3.80.0030.00715.04
7.3.70.0050.00514.85
7.3.60.0060.00914.90
7.3.50.0110.00014.47
7.3.40.0000.01414.64
7.3.30.0060.00614.75
7.3.20.0070.00316.68
7.3.10.0080.00516.73
7.3.00.0070.00516.59
7.2.330.0090.00916.93
7.2.320.0040.01716.82
7.2.310.0070.01016.93
7.2.300.0090.01017.00
7.2.290.0110.00616.88
7.2.250.0100.00315.12
7.2.240.0090.00914.98
7.2.230.0070.01014.93
7.2.220.0070.01015.18
7.2.210.0060.00815.51
7.2.200.0040.00815.04
7.2.190.0040.01115.16
7.2.180.0060.00615.09
7.2.170.0040.01215.17
7.2.160.0000.01215.01
7.2.150.0070.01116.98
7.2.140.0120.00317.03
7.2.130.0060.00916.83
7.2.120.0080.00517.03
7.2.110.0060.00716.95
7.2.100.0050.00816.79
7.2.90.0050.00916.96
7.2.80.0080.00816.90
7.2.70.0020.01317.07
7.2.60.0050.00817.01
7.2.50.0050.00917.01
7.2.40.0030.01116.99
7.2.30.0050.00817.06
7.2.20.0080.00816.96
7.2.10.0080.00816.79
7.2.00.0040.00917.70
7.1.330.0070.01115.89
7.1.320.0050.00515.70
7.1.310.0050.00515.73
7.1.300.0090.00615.71
7.1.290.0080.00415.91
7.1.280.0030.00615.89
7.1.270.0030.00915.95
7.1.260.0090.00616.01
7.1.250.0040.01115.92
7.1.240.0030.00615.83
7.1.230.0100.00315.87
7.1.220.0080.00515.60
7.1.210.0040.01115.84
7.1.200.0050.00915.82
7.1.190.0070.00515.86
7.1.180.0080.00415.72
7.1.170.0020.00915.85
7.1.160.0070.00515.76
7.1.150.0070.00715.87
7.1.140.0020.01015.78
7.1.130.0040.01015.89
7.1.120.0040.00815.89
7.1.110.0040.00915.91
7.1.100.0060.00815.96
7.1.90.0080.00315.62
7.1.80.0090.00515.76
7.1.70.0050.00616.31
7.1.60.0100.00316.24
7.1.50.0120.00822.34
7.1.40.0030.00815.70
7.1.30.0030.00716.01
7.1.20.0070.00915.89
7.1.10.0120.02917.95
7.1.00.0060.02717.99
7.0.330.0030.00815.17
7.0.320.0050.00715.51
7.0.310.0040.01115.30
7.0.300.0070.00615.27
7.0.290.0050.00515.50
7.0.280.0090.00715.23
7.0.270.0070.00715.33
7.0.260.0070.00415.47
7.0.250.0040.00615.53
7.0.240.0030.01015.61
7.0.230.0050.00515.19
7.0.220.0070.00615.32
7.0.210.0080.00715.41
7.0.200.0040.01116.03
7.0.190.0020.00815.41
7.0.180.0050.00815.38
7.0.170.0050.00615.38
7.0.160.0050.00715.34
7.0.150.0080.02317.60
7.0.140.0050.02717.52
7.0.130.0060.02217.62
7.0.120.0080.02417.50
7.0.110.0070.03117.55
7.0.100.0060.02417.55
7.0.90.0030.02717.69
7.0.80.0040.02317.52
7.0.70.0080.02217.60
7.0.60.0060.02617.56
7.0.50.0030.02517.64
7.0.40.0030.02916.30
7.0.30.0070.02316.38
7.0.20.0050.02416.36
7.0.10.0060.02316.15
7.0.00.0060.02416.31
5.6.400.0060.00314.39
5.6.390.0070.00414.23
5.6.380.0040.01114.14
5.6.370.0110.00314.12
5.6.360.0080.00013.79
5.6.350.0040.01113.95
5.6.340.0030.00614.14
5.6.330.0090.00014.11
5.6.320.0060.00613.88
5.6.310.0070.00714.30
5.6.300.0050.01014.26
5.6.290.0070.00714.24
5.6.280.0030.01014.18
5.6.270.0070.00714.10
5.6.260.0000.01114.13
5.6.250.0120.00314.19
5.6.240.0040.01114.06
5.6.230.0090.00313.96
5.6.220.0000.01114.23
5.6.210.0030.01013.80
5.6.200.0040.00713.88
5.6.190.0080.00414.14
5.6.180.0050.00314.09
5.6.170.0040.01114.20
5.6.160.0000.01314.15
5.6.150.0000.01114.38
5.6.140.0090.00313.96
5.6.130.0040.00714.16
5.6.120.0080.00414.18
5.6.110.0000.00813.86
5.6.100.0070.00714.11
5.6.90.0070.00714.00
5.6.80.0000.01114.18
5.6.70.0080.00814.07
5.6.60.0070.00414.02
5.6.50.0070.01014.27
5.6.40.0040.00413.86
5.6.30.0060.00614.03
5.6.20.0040.00814.27
5.6.10.0000.01213.86
5.6.00.0000.00914.10

preferences:
32.84 ms | 400 KiB | 5 Q