3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Luhn { public static function getDigit($number) { $number .= 0; $result = self::calc($number); echo $result; return (10 - $result); } public static function calc($number) { $sum = 0; $numDigits = strlen($number) - 1; $parity = $numDigits % 2; for ($i = $numDigits; $i >= 0; $i--) { $digit = substr($number, $i, 1); if (!$parity == ($i % 2)) {$digit <<= 1;} $digit = ($digit > 9) ? ($digit - 9) : $digit; $sum += $digit; } return ($sum % 10); } public static function check($number) { return (0 == self::calc()); } } $checkd = Luhn::getDigit(1234567891234567891); echo $checkd; var_dump(Luhn::check("1234567891234567891" . $checkd));

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.70.0060.00916.75
8.3.60.0160.00616.74
8.3.50.0100.00922.18
8.3.40.0070.00718.63
8.3.30.0110.00418.79
8.3.20.0040.00420.39
8.3.10.0070.00023.61
8.3.00.0080.00019.48
8.2.180.0040.01218.41
8.2.170.0070.01122.96
8.2.160.0130.00320.21
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0060.00317.75
8.2.120.0000.00826.35
8.2.110.0070.00319.33
8.2.100.0080.00417.88
8.2.90.0040.00419.36
8.2.80.0050.00317.97
8.2.70.0030.00617.38
8.2.60.0030.00618.04
8.2.50.0080.00018.07
8.2.40.0040.00419.40
8.2.30.0000.00720.57
8.2.20.0030.00617.82
8.2.10.0040.00418.12
8.2.00.0050.00318.17
8.1.280.0030.01425.92
8.1.270.0040.00423.82
8.1.260.0040.00428.09
8.1.250.0060.00328.09
8.1.240.0000.00922.01
8.1.230.0090.00317.77
8.1.220.0040.00417.76
8.1.210.0060.00318.77
8.1.200.0030.00617.35
8.1.190.0030.00617.76
8.1.180.0060.00318.10
8.1.170.0080.00018.61
8.1.160.0030.00522.02
8.1.150.0050.00218.78
8.1.140.0040.00419.54
8.1.130.0070.00017.63
8.1.120.0040.00417.50
8.1.110.0040.00417.38
8.1.100.0100.00017.36
8.1.90.0000.00817.52
8.1.80.0000.00817.36
8.1.70.0030.00617.48
8.1.60.0000.00817.50
8.1.50.0040.00417.50
8.1.40.0080.00017.52
8.1.30.0090.00017.63
8.1.20.0040.00417.64
8.1.10.0000.00817.48
8.1.00.0000.00817.42
8.0.300.0000.00718.77
8.0.290.0000.00716.75
8.0.280.0030.00318.41
8.0.270.0000.00717.23
8.0.260.0030.00317.32
8.0.250.0050.00316.93
8.0.240.0070.00016.92
8.0.230.0000.01016.96
8.0.220.0030.00316.90
8.0.210.0000.00716.87
8.0.200.0050.00217.02
8.0.190.0000.00817.06
8.0.180.0000.00716.98
8.0.170.0000.00717.00
8.0.160.0000.00817.02
8.0.150.0070.00016.88
8.0.140.0040.00416.88
8.0.130.0000.00513.35
8.0.120.0030.00516.99
8.0.110.0020.00516.86
8.0.100.0050.00217.00
8.0.90.0070.00016.91
8.0.80.0090.00616.95
8.0.70.0050.00316.82
8.0.60.0030.00517.07
8.0.50.0040.00416.84
8.0.30.0100.00917.11
8.0.20.0120.00617.41
8.0.10.0000.00716.90
8.0.00.0110.00716.76
7.4.330.0050.00016.85
7.4.320.0070.00016.53
7.4.300.0060.00016.54
7.4.290.0000.00716.63
7.4.280.0000.00816.57
7.4.270.0070.00016.51
7.4.260.0030.00316.64
7.4.250.0000.00816.63
7.4.240.0000.00716.51
7.4.230.0030.00316.52
7.4.220.0090.01016.74
7.4.210.0110.00816.59
7.4.200.0000.00716.37
7.4.160.0120.00916.53
7.4.150.0070.01317.40
7.4.140.0140.01017.86
7.4.130.0060.01216.54
7.4.120.0110.00816.59
7.4.110.0100.00716.43
7.4.100.0070.01016.57
7.4.90.0080.00816.48
7.4.80.0030.01319.39
7.4.70.0080.00816.64
7.4.60.0090.00816.49
7.4.50.0000.01216.43
7.4.40.0100.01016.52
7.4.30.0130.00916.59
7.4.00.0060.01314.88
7.3.330.0050.00013.42
7.3.320.0000.00513.43
7.3.310.0000.00716.46
7.3.300.0070.00016.44
7.3.290.0040.00416.40
7.3.280.0060.01216.45
7.3.270.0110.00617.40
7.3.260.0120.00616.51
7.3.250.0110.00716.38
7.3.240.0100.00816.63
7.3.230.0030.02016.51
7.3.210.0060.01216.37
7.3.200.0170.00016.45
7.3.190.0100.00616.63
7.3.180.0060.01216.55
7.3.170.0070.01116.40
7.3.160.0030.01216.41
7.3.120.0030.01315.34
7.3.110.0080.00715.56
7.3.100.0080.00815.49
7.3.90.0060.01015.56
7.3.80.0040.01115.45
7.3.70.0070.00615.41
7.3.60.0070.00815.39
7.3.50.0050.00915.49
7.3.40.0030.01115.43
7.3.30.0020.01115.38
7.3.20.0040.00816.88
7.3.10.0050.00916.74
7.3.00.0050.00916.73
7.2.330.0040.01416.90
7.2.320.0090.00916.49
7.2.310.0130.01016.80
7.2.300.0060.01016.54
7.2.290.0130.00316.59
7.2.250.0070.01315.17
7.2.240.0080.01115.59
7.2.230.0090.00715.63
7.2.220.0090.00615.50
7.2.210.0070.00915.55
7.2.200.0040.00815.58
7.2.190.0050.00815.60
7.2.180.0090.00515.60
7.2.170.0060.00715.54
7.2.160.0000.01117.15
7.2.150.0000.01817.15
7.2.140.0070.01017.15
7.2.130.0070.01117.15
7.2.120.0060.00917.15
7.2.110.0080.00517.15
7.2.100.0090.00317.15
7.2.90.0060.00917.15
7.2.80.0060.01017.15
7.2.70.0070.01017.15
7.2.60.0040.01217.00
7.2.50.0070.01017.15
7.2.40.0060.00917.15
7.2.30.0070.01117.15
7.2.20.0090.00917.15
7.2.10.0000.01817.15
7.2.00.0050.01118.33
7.1.330.0050.00816.23
7.1.320.0050.00616.01
7.1.310.0060.00816.06
7.1.300.0060.00716.07
7.1.290.0050.00816.08
7.1.280.0080.00616.11
7.1.270.0030.01216.16
7.1.260.0010.01216.05
7.1.250.0060.00317.15
7.1.200.0100.00315.93
7.1.100.0060.00918.29
7.1.70.0000.00717.05
7.1.60.0030.02019.36
7.1.50.0000.02017.11
7.1.00.0000.08022.40
7.0.200.0000.00916.88
7.0.60.0130.05719.80
7.0.50.0100.07317.87
7.0.40.0070.08320.40
7.0.30.0300.05020.10
7.0.20.0200.04720.19
7.0.10.0100.06320.08
7.0.00.0130.08020.16
5.6.280.0000.03721.08
5.6.210.0100.07020.77
5.6.200.0130.07718.12
5.6.190.0130.07020.39
5.6.180.0370.07720.48
5.6.170.0330.05720.39
5.6.160.0030.08020.43
5.6.150.0000.04318.17
5.6.140.0100.08018.19
5.6.130.0030.04018.21
5.6.120.0130.07721.09
5.6.110.0030.07320.98
5.6.100.0170.06321.14
5.6.90.0100.03721.12
5.6.80.0100.08020.44
5.5.350.0230.07720.43
5.5.340.0070.05717.95
5.5.330.0000.05720.23
5.5.320.0030.04020.37
5.5.310.0230.03720.50
5.5.300.0030.05717.94
5.5.290.0070.04717.95
5.5.280.0070.04320.66
5.5.270.0130.07020.98
5.5.260.0130.08020.85
5.5.250.0100.08020.70
5.5.240.0030.08320.07

preferences:
47.14 ms | 401 KiB | 5 Q