3v4l.org

run code in 300+ PHP versions simultaneously
<?php class IdentificationNumber { private const VALIDATION_EXPR = '/ ^ (?<part1> \d{1,2} | N | P?E | \d{1,2}PI ) - (?<part2> \d{1,5} ) - (?<part3> \d{1,6} ) $ /ix'; private $part1; private $part2; private $part3; public function __construct(string $input) { if (!\preg_match(self::VALIDATION_EXPR, $input, $match)) { throw new \DomainException('Invalid identification number: ' . $input); } $this->part1 = \strtoupper($match['part1']); $this->part2 = $match['part2']; $this->part3 = $match['part3']; } public function getPart1(): string { return $this->part1; } public function getPart2(): string { return $this->part2; } public function getPart3(): string { return $this->part3; } public function __toString(): string { return "{$this->part1}-{$this->part2}-{$this->part3}"; } } function procedure_that_needs_valid_id(IdentificationNumber $id) { echo "{$id} is valid\n"; } $tests = [ '3-728-2208', '1-728-2208', '22PI-55555-666666', 'PE-333-333', 'PÉ-1-4444', 'N-4444-55555', 'Ñ-22-22', 'E-1-1', ]; foreach ($tests as $test) { try { procedure_that_needs_valid_id(new IdentificationNumber($test)); } catch (\DomainException $e) { echo "{$e->getMessage()}\n"; } }

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.80.0070.00318.68
8.3.70.0090.00618.39
8.3.60.0040.01518.43
8.3.50.0080.00718.39
8.3.40.0170.00019.08
8.3.30.0040.01519.02
8.3.20.0080.00021.77
8.3.10.0080.00023.52
8.3.00.0040.00421.73
8.2.200.0090.00018.41
8.2.190.0040.01116.63
8.2.180.0100.00716.75
8.2.170.0120.00322.96
8.2.160.0110.00322.08
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0050.00220.39
8.2.120.0070.00026.35
8.2.110.0030.00622.23
8.2.100.0110.00017.97
8.2.90.0100.00019.17
8.2.80.0040.00417.97
8.2.70.0050.00318.00
8.2.60.0090.00018.05
8.2.50.0030.00518.22
8.2.40.0000.00820.53
8.2.30.0040.00419.39
8.2.20.0000.00718.16
8.2.10.0050.00218.21
8.2.00.0040.00418.23
8.1.290.0000.00918.88
8.1.280.0090.00625.92
8.1.270.0070.00023.92
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00623.92
8.1.230.0080.00319.50
8.1.220.0030.00517.74
8.1.210.0060.00318.77
8.1.200.0070.00317.38
8.1.190.0040.00417.47
8.1.180.0080.00018.10
8.1.170.0080.00018.78
8.1.160.0050.00318.89
8.1.150.0000.00818.87
8.1.140.0050.00319.11
8.1.130.0040.00417.88
8.1.120.0040.00317.70
8.1.110.0000.00817.66
8.1.100.0000.00717.63
8.1.90.0040.00417.65
8.1.80.0040.00417.68
8.1.70.0000.00817.55
8.1.60.0030.00517.74
8.1.50.0050.00317.70
8.1.40.0040.00417.67
8.1.30.0030.00517.77
8.1.20.0050.00317.66
8.1.10.0000.00917.76
8.1.00.0040.00417.66
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0030.00318.57
8.0.270.0000.00717.18
8.0.260.0030.00317.35
8.0.250.0000.00717.20
8.0.240.0030.00317.18
8.0.230.0090.00017.09
8.0.220.0080.00317.14
8.0.210.0050.00316.99
8.0.200.0000.00817.15
8.0.190.0070.00017.23
8.0.180.0040.00417.20
8.0.170.0040.00417.07
8.0.160.0000.00717.02
8.0.150.0070.00017.07
8.0.140.0040.00417.14
8.0.130.0000.00513.51
8.0.120.0000.00816.97
8.0.110.0020.00517.14
8.0.100.0030.00516.91
8.0.90.0040.00416.95
8.0.80.0060.00917.12
8.0.70.0080.00017.19
8.0.60.0030.00517.19
8.0.50.0040.00417.23
8.0.30.0090.00917.41
8.0.20.0130.00717.45
8.0.10.0040.00417.21
8.0.00.0100.00717.07
7.4.330.0000.00515.55
7.4.320.0030.00316.85
7.4.300.0030.00316.73
7.4.290.0030.00316.88
7.4.280.0030.00716.68
7.4.270.0030.00316.74
7.4.260.0080.00016.84
7.4.250.0040.00416.70
7.4.240.0000.00716.68
7.4.230.0040.00416.68
7.4.220.0030.00516.84
7.4.210.0000.01516.70
7.4.200.0030.00316.87
7.4.160.0070.01016.76
7.4.150.0060.01217.40
7.4.140.0140.00817.86
7.4.130.0150.00916.84
7.4.120.0100.01216.73
7.4.110.0060.01216.87
7.4.100.0110.00816.77
7.4.90.0070.01016.74
7.4.80.0140.00319.39
7.4.70.0090.00916.54
7.4.60.0030.01316.57
7.4.50.0120.00316.76
7.4.40.0060.01216.67
7.4.30.0120.01216.56
7.4.00.0100.00615.20
7.3.330.0000.00613.50
7.3.320.0030.00313.58
7.3.310.0070.00016.63
7.3.300.0030.00316.45
7.3.290.0070.00916.52
7.3.280.0070.00916.53
7.3.270.0100.00717.40
7.3.260.0080.01116.71
7.3.250.0080.00916.68
7.3.240.0100.00716.57
7.3.230.0130.00516.59
7.3.210.0120.01616.58
7.3.200.0120.00616.57
7.3.190.0110.00616.81
7.3.180.0070.01116.46
7.3.170.0030.01316.63
7.3.160.0090.00616.56
7.3.120.0070.00715.22
7.3.110.0000.01515.04
7.3.100.0150.00014.96
7.3.90.0040.01114.71
7.3.80.0080.00415.12
7.3.70.0080.00815.10
7.3.60.0030.00515.01
7.3.50.0090.00014.55
7.3.40.0070.00315.07
7.3.30.0000.01714.76
7.3.20.0080.00816.97
7.3.10.0070.00717.14
7.3.00.0110.00416.85
7.2.330.0140.00416.85
7.2.320.0030.01516.91
7.2.310.0060.01117.05
7.2.300.0060.01216.88
7.2.290.0170.00016.95
7.2.240.0060.00914.86
7.2.230.0090.00615.47
7.2.220.0080.00415.36
7.2.210.0080.00415.14
7.2.200.0030.01215.44
7.2.190.0070.00415.50
7.2.180.0000.01515.27
7.2.170.0100.00315.29
7.2.160.0110.00415.36
7.2.150.0090.00317.34
7.2.140.0100.00617.29
7.2.130.0080.00617.06
7.2.120.0080.00417.23
7.2.110.0070.01017.04
7.2.100.0120.00317.18
7.2.90.0070.00716.78
7.2.80.0040.00817.26
7.2.70.0030.01317.22
7.2.60.0040.01117.00
7.2.50.0080.00517.22
7.2.40.0070.01117.20
7.2.30.0100.00617.02
7.2.20.0070.01117.14
7.2.10.0030.01316.79
7.2.00.0060.01019.02
7.1.330.0100.00016.30
7.1.320.0000.01716.00
7.1.310.0030.01015.61
7.1.300.0000.01116.21
7.1.290.0060.00616.07
7.1.280.0100.00315.94
7.1.270.0150.00016.13
7.1.260.0040.00815.88
7.1.250.0060.00915.99
7.1.200.0040.00815.70
7.1.120.0060.00919.02
7.1.110.0030.01018.55
7.1.100.0070.00618.15
7.1.90.0030.01018.12
7.1.80.0080.01118.18
7.1.70.0080.01117.14
7.1.60.0200.01735.51
7.1.50.0200.01034.93
7.1.40.0240.01134.68
7.1.30.0230.01534.66
7.1.20.0200.01434.72
7.1.10.0030.01416.91
7.1.00.0030.01617.04

preferences:
32.47 ms | 401 KiB | 5 Q