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 = "99/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.4.20.0140.00718.08
8.4.10.0090.00019.97
8.3.150.0040.01516.98
8.3.140.0080.00018.91
8.3.130.0030.00618.69
8.3.120.0040.00420.98
8.3.110.0040.00417.16
8.3.100.0110.00716.80
8.3.90.0090.00026.77
8.3.80.0030.00618.80
8.3.70.0160.00016.88
8.3.60.0110.00718.68
8.3.50.0050.01222.23
8.3.40.0110.00419.21
8.3.30.0040.01119.04
8.3.20.0030.00522.07
8.3.10.0050.00220.29
8.3.00.0000.00919.93
8.2.260.0060.00317.12
8.2.250.0080.00016.79
8.2.240.0070.00717.05
8.2.230.0110.00420.94
8.2.220.0130.00324.06
8.2.210.0070.00726.77
8.2.200.0090.00018.79
8.2.190.0080.00816.88
8.2.180.0120.00916.75
8.2.170.0150.00022.96
8.2.160.0100.00320.53
8.2.150.0050.00324.18
8.2.140.0030.00624.66
8.2.130.0050.00318.22
8.2.120.0050.00226.35
8.2.110.0100.00019.45
8.2.100.0050.00520.13
8.2.90.0000.00819.17
8.2.80.0060.00318.00
8.2.70.0000.00818.00
8.2.60.0040.00418.05
8.2.50.0030.00618.13
8.2.40.0000.00918.41
8.2.30.0050.00518.10
8.2.20.0060.00318.16
8.2.10.0070.00018.10
8.2.00.0020.00518.04
8.1.310.0070.00716.73
8.1.300.0040.00416.41
8.1.290.0030.00618.88
8.1.280.0120.00625.92
8.1.270.0070.00022.10
8.1.260.0070.00026.35
8.1.250.0060.00328.09
8.1.240.0040.00422.61
8.1.230.0040.00722.12
8.1.220.0030.00617.74
8.1.210.0050.00318.77
8.1.200.0060.00317.60
8.1.190.0000.00817.48
8.1.180.0030.00618.10
8.1.170.0000.00918.84
8.1.160.0040.00418.84
8.1.150.0040.00422.12
8.1.140.0030.00619.71
8.1.130.0030.00319.16
8.1.120.0070.00017.81
8.1.110.0030.00517.74
8.1.100.0040.00417.73
8.1.90.0000.00717.64
8.1.80.0000.00717.71
8.1.70.0030.00317.65
8.1.60.0000.00917.78
8.1.50.0080.00317.69
8.1.40.0030.00617.65
8.1.30.0060.00317.86
8.1.20.0050.00517.92
8.1.10.0080.00017.70
8.1.00.0080.00017.77
8.0.300.0040.00418.77
8.0.290.0040.00417.00
8.0.280.0000.00718.54
8.0.270.0050.00317.35
8.0.260.0000.00717.27
8.0.250.0050.00317.27
8.0.240.0000.00717.25
8.0.230.0070.00417.21
8.0.220.0050.00217.13
8.0.210.0000.00717.20
8.0.200.0030.00317.29
8.0.190.0000.00717.22
8.0.180.0000.00817.24
8.0.170.0000.00717.24
8.0.160.0040.00417.21
8.0.150.0040.00417.14
8.0.140.0030.00617.23
8.0.130.0060.00013.65
8.0.120.0050.00217.11
8.0.110.0040.00417.24
8.0.100.0000.00717.10
8.0.90.0030.00517.25
8.0.80.0120.00917.20
8.0.70.0040.00417.19
8.0.60.0000.00817.09
8.0.50.0000.00817.08
8.0.30.0080.00917.41
8.0.20.0150.00817.45
8.0.10.0050.00317.24
8.0.00.0140.00317.29
7.4.330.0040.00415.55
7.4.320.0060.00016.85
7.4.300.0000.00616.90
7.4.290.0030.00316.80
7.4.280.0050.00516.89
7.4.270.0030.00316.70
7.4.260.0040.00416.88
7.4.250.0050.00316.85
7.4.240.0000.00716.70
7.4.230.0000.00716.74
7.4.220.0130.00616.82
7.4.210.0070.01416.90
7.4.200.0000.00716.92
7.4.160.0060.01016.79
7.4.150.0120.00617.40
7.4.140.0130.00517.86
7.4.130.0060.01216.98
7.4.120.0110.01016.88
7.4.110.0110.00716.96
7.4.100.0090.00916.88
7.4.90.0130.00716.74
7.4.80.0130.00319.39
7.4.70.0030.01416.71
7.4.60.0120.00616.89
7.4.50.0060.01016.95
7.4.40.0120.00416.64
7.4.30.0100.00616.65
7.4.10.0100.00315.26
7.4.00.0080.00815.25
7.3.330.0040.00213.43
7.3.320.0000.00513.60
7.3.310.0000.00716.62
7.3.300.0000.00816.55
7.3.290.0090.00516.66
7.3.280.0080.00916.66
7.3.270.0130.01017.40
7.3.260.0100.00816.81
7.3.250.0110.00716.79
7.3.240.0090.01016.70
7.3.230.0100.00716.84
7.3.210.0060.01016.66
7.3.200.0070.01016.82
7.3.190.0040.01216.67
7.3.180.0070.01016.92
7.3.170.0030.01316.90
7.3.160.0100.00716.74
7.3.130.0070.01015.24
7.3.120.0120.00415.18
7.3.110.0060.01215.14
7.3.100.0060.00915.22
7.3.90.0000.01214.96
7.3.80.0070.00414.98
7.3.70.0120.00314.88
7.3.60.0030.01014.97
7.3.50.0000.00915.22
7.3.40.0030.00715.30
7.3.30.0070.00715.31
7.3.20.0090.00316.94
7.3.10.0000.00917.13
7.3.00.0060.00917.13
7.2.330.0110.00817.13
7.2.320.0130.00317.07
7.2.310.0110.00716.98
7.2.300.0150.00916.90
7.2.290.0100.00617.10
7.2.260.0060.01015.13
7.2.250.0090.00915.40
7.2.240.0060.00615.40
7.2.230.0060.00915.56
7.2.220.0030.00715.27
7.2.210.0040.01115.38
7.2.200.0030.01015.56
7.2.190.0030.01115.40
7.2.180.0000.01015.17
7.2.170.0030.00915.50
7.2.160.0030.00715.54
7.2.150.0080.00817.18
7.2.140.0040.01417.05
7.2.130.0090.00917.27
7.2.120.0070.00717.14
7.2.110.0090.00617.01
7.2.100.0030.00916.95
7.2.90.0090.00317.30
7.2.80.0060.00617.44
7.2.70.0110.00417.34
7.2.60.0070.00617.26
7.2.50.0060.00317.18
7.2.40.0000.01617.38
7.2.30.0040.01117.27
7.2.20.0040.00917.30
7.2.10.0040.00817.22
7.2.00.0060.00718.49
7.1.330.0130.00016.03
7.1.320.0000.01515.98
7.1.310.0000.01215.96
7.1.300.0030.01016.14
7.1.290.0000.00816.21
7.1.280.0040.00816.09
7.1.270.0040.00415.95
7.1.260.0070.00716.18
7.1.250.0080.00316.05
7.1.240.0040.00415.86
7.1.230.0070.00415.77
7.1.220.0030.01016.23
7.1.210.0000.01215.96
7.1.200.0070.00716.11
7.1.190.0120.00015.97
7.1.180.0080.00316.13
7.1.170.0080.00416.13
7.1.160.0110.00716.20
7.1.150.0030.00716.01
7.1.140.0070.00715.87
7.1.130.0030.01416.04
7.1.120.0040.01415.92
7.1.110.0030.01016.23
7.1.100.0030.00817.24
7.1.90.0070.00715.94
7.1.80.0060.00915.98
7.1.70.0050.00916.69
7.1.60.0060.00916.90
7.1.50.0050.01116.57
7.1.40.0030.01016.11
7.1.30.0100.00716.05
7.1.20.0000.01516.08
7.1.10.0160.02819.11
7.1.00.0070.03219.29
7.0.330.0060.00615.70
7.0.320.0090.00615.65
7.0.310.0070.00415.36
7.0.300.0120.00415.96
7.0.290.0060.00615.96
7.0.280.0060.00315.74
7.0.270.0040.00415.46
7.0.260.0000.01815.71
7.0.250.0060.00915.88
7.0.240.0060.00615.79
7.0.230.0070.00315.41
7.0.220.0100.00615.68
7.0.210.0070.01115.71
7.0.200.0110.00616.35
7.0.190.0030.00615.66
7.0.180.0120.00315.42
7.0.170.0070.00715.55
7.0.160.0060.00815.81
7.0.150.0120.03318.71
7.0.140.0050.03518.71
7.0.130.0080.03918.83
7.0.120.0130.04218.87
7.0.110.0070.03518.66
7.0.100.0030.03518.69
7.0.90.0080.03318.80
7.0.80.0070.03318.92
7.0.70.0060.03318.86
7.0.60.0060.03418.81
7.0.50.0070.02918.69
7.0.40.0080.03017.88
7.0.30.0070.02817.84
7.0.20.0090.04117.91
7.0.10.0070.03217.93
7.0.00.0050.03117.91
5.6.400.0030.01314.27
5.6.390.0070.00714.13
5.6.380.0120.00314.25
5.6.370.0100.00714.18
5.6.360.0090.00314.13
5.6.350.0080.00414.12
5.6.340.0000.01514.25
5.6.330.0070.00314.32
5.6.320.0000.01314.32
5.6.310.0100.01013.84
5.6.300.0060.00914.41
5.6.290.0040.01113.90
5.6.280.0030.00614.05
5.6.270.0030.01314.09
5.6.260.0090.00314.12
5.6.250.0060.00614.01
5.6.240.0060.00614.09
5.6.230.0040.01113.98
5.6.220.0100.00313.98
5.6.210.0030.00714.08
5.6.200.0060.00614.19
5.6.190.0000.01213.96
5.6.180.0080.00414.14
5.6.170.0070.00713.96
5.6.160.0030.01014.12
5.6.150.0100.00313.95
5.6.140.0080.00414.05
5.6.130.0000.01213.91
5.6.120.0030.00914.42
5.6.110.0000.01513.92
5.6.100.0060.00314.05
5.6.90.0070.00714.35
5.6.80.0000.00913.96
5.6.70.0040.00413.77
5.6.60.0000.01613.98
5.6.50.0070.00713.93
5.6.40.0060.00314.20
5.6.30.0030.01013.91
5.6.20.0060.00614.14
5.6.10.0070.00713.85
5.6.00.0000.01314.06

preferences:
21.85 ms | 403 KiB | 5 Q