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::cacl()); } } $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.60.0110.00716.49
8.3.50.0060.00918.17
8.3.40.0100.01018.97
8.3.30.0110.00318.97
8.3.20.0000.00720.16
8.3.10.0000.00823.66
8.3.00.0000.00819.50
8.2.180.0120.00316.63
8.2.170.0070.01422.96
8.2.160.0100.00320.35
8.2.150.0040.00424.18
8.2.140.0000.00724.66
8.2.130.0040.00417.50
8.2.120.0080.00026.35
8.2.110.0040.00720.94
8.2.100.0100.00317.63
8.2.90.0080.00019.36
8.2.80.0080.00017.97
8.2.70.0000.00817.63
8.2.60.0040.00417.93
8.2.50.0030.00518.07
8.2.40.0030.00619.45
8.2.30.0040.00420.60
8.2.20.0000.00917.83
8.2.10.0070.00018.13
8.2.00.0050.00318.11
8.1.270.0080.00023.97
8.1.260.0040.00428.09
8.1.250.0120.00028.09
8.1.240.0090.00022.19
8.1.230.0120.00017.79
8.1.220.0040.00417.74
8.1.210.0030.00618.77
8.1.200.0060.00317.38
8.1.190.0000.00817.63
8.1.180.0060.00318.10
8.1.170.0000.00718.62
8.1.160.0000.00722.09
8.1.150.0040.00418.81
8.1.140.0030.00619.49
8.1.130.0080.00017.75
8.1.120.0000.00717.48
8.1.110.0070.00017.44
8.1.100.0000.00817.45
8.1.90.0000.00717.45
8.1.80.0000.00917.47
8.1.70.0060.00317.29
8.1.60.0040.00417.63
8.1.50.0030.00617.50
8.1.40.0040.00417.40
8.1.30.0030.00617.69
8.1.20.0000.00817.59
8.1.10.0030.00617.63
8.1.00.0000.00917.51
8.0.300.0000.00718.77
8.0.290.0070.00016.75
8.0.280.0000.00718.51
8.0.270.0030.00317.18
8.0.260.0000.00817.18
8.0.250.0000.00816.93
8.0.240.0040.00417.02
8.0.230.0030.00616.88
8.0.220.0050.00216.96
8.0.210.0000.00816.97
8.0.200.0040.00417.01
8.0.190.0060.00317.03
8.0.180.0000.00716.99
8.0.170.0030.00316.97
8.0.160.0030.00616.96
8.0.150.0000.00716.94
8.0.140.0030.00416.93
8.0.130.0060.00013.38
8.0.120.0000.00816.89
8.0.110.0040.00417.00
8.0.100.0000.00716.93
8.0.90.0040.00416.96
8.0.80.0070.00717.03
8.0.70.0000.00816.96
8.0.60.0000.00716.95
8.0.50.0000.00716.97
8.0.30.0110.00717.09
8.0.20.0090.01017.40
8.0.10.0050.00317.09
8.0.00.0090.01017.05
7.4.330.0000.00516.80
7.4.320.0000.00616.48
7.4.300.0030.00316.53
7.4.290.0050.00216.57
7.4.280.0080.00016.50
7.4.270.0030.00316.46
7.4.260.0000.00816.63
7.4.250.0040.00416.47
7.4.240.0000.00816.53
7.4.230.0030.00316.62
7.4.220.0120.00616.73
7.4.210.0040.01116.71
7.4.200.0000.00716.61
7.4.160.0160.00316.54
7.4.150.0120.00917.40
7.4.140.0070.01317.86
7.4.130.0100.01016.49
7.4.120.0170.00416.58
7.4.110.0100.00716.62
7.4.100.0110.01116.63
7.4.90.0110.00716.34
7.4.80.0140.00319.39
7.4.70.0080.00916.65
7.4.60.0100.00716.53
7.4.50.0030.01316.73
7.4.40.0110.01116.64
7.4.30.0030.01916.60
7.4.10.0060.01214.93
7.4.00.0050.01414.95
7.3.330.0060.00013.43
7.3.320.0050.00013.43
7.3.310.0030.00316.47
7.3.300.0050.00216.32
7.3.290.0000.00716.43
7.3.280.0070.01016.42
7.3.270.0120.00617.40
7.3.260.0060.01316.41
7.3.250.0130.00716.56
7.3.240.0110.00616.50
7.3.230.0070.01116.39
7.3.210.0190.00316.34
7.3.200.0060.00916.75
7.3.190.0130.00316.54
7.3.180.0130.00316.44
7.3.170.0060.01516.69
7.3.160.0040.01116.34
7.3.130.0100.00714.93
7.3.120.0050.01214.94
7.3.110.0040.01214.66
7.3.100.0050.00914.82
7.3.90.0080.00514.92
7.3.80.0030.01214.97
7.3.70.0030.01314.90
7.3.60.0050.00914.73
7.3.50.0050.01014.85
7.3.40.0050.00914.94
7.3.30.0020.01114.93
7.3.20.0030.01016.79
7.3.10.0060.00616.68
7.3.00.0050.00816.64
7.2.330.0060.01016.88
7.2.320.0060.01516.58
7.2.310.0060.01616.94
7.2.300.0100.00716.79
7.2.290.0120.00416.80
7.2.260.0070.01614.83
7.2.250.0070.01114.90
7.2.240.0050.01214.91
7.2.230.0090.00515.06
7.2.220.0120.00615.11
7.2.210.0090.00714.98
7.2.200.0050.00915.23
7.2.190.0080.00714.86
7.2.180.0070.00614.97
7.2.170.0040.00914.84
7.2.160.0060.00914.94
7.2.150.0100.00717.02
7.2.140.0090.00916.79
7.2.130.0070.00816.66
7.2.120.0050.00916.63
7.2.110.0110.00616.52
7.2.100.0070.00816.89
7.2.90.0040.01016.96
7.2.80.0050.01016.88
7.2.70.0070.00916.91
7.2.60.0050.01016.92
7.2.50.0070.00616.85
7.2.40.0060.00716.92
7.2.30.0050.00816.94
7.2.20.0050.01216.81
7.2.10.0050.00816.87
7.2.00.0090.00517.80
7.1.330.0090.00415.88
7.1.320.0090.00615.77
7.1.310.0050.00815.88
7.1.300.0080.00615.84
7.1.290.0080.00515.90
7.1.280.0080.00715.82
7.1.270.0030.00715.65
7.1.260.0060.00915.96
7.1.250.0040.00815.75
7.1.240.0080.00415.83
7.1.230.0030.01215.88
7.1.220.0130.00315.88
7.1.210.0040.00815.63
7.1.200.0090.00415.84
7.1.190.0060.00615.73
7.1.180.0110.00315.69
7.1.170.0080.00615.70
7.1.160.0040.00715.90
7.1.150.0030.01215.98
7.1.140.0060.00915.88
7.1.130.0110.00315.89
7.1.120.0070.00715.79
7.1.110.0060.00316.00
7.1.100.0030.01216.96
7.1.90.0120.00015.65
7.1.80.0050.00815.57
7.1.70.0060.01116.56
7.1.60.0060.01117.63
7.1.50.0030.01416.42
7.1.40.0070.00715.63
7.1.30.0040.00415.79
7.1.20.0000.01515.58
7.1.10.0070.00415.77
7.1.00.0030.04019.08
7.0.330.0060.00315.41
7.0.320.0000.01515.21
7.0.310.0110.00315.43
7.0.300.0040.01115.46
7.0.290.0030.01015.35
7.0.280.0090.00315.57
7.0.270.0070.00715.49
7.0.260.0070.00715.40
7.0.250.0000.00915.29
7.0.240.0030.01015.37
7.0.230.0040.01115.48
7.0.220.0080.00415.68
7.0.210.0000.01115.55
7.0.200.0050.00516.08
7.0.190.0080.00415.31
7.0.180.0000.00815.58
7.0.170.0130.00315.59
7.0.160.0120.00315.55
7.0.150.0040.00815.36
7.0.140.0040.00715.65
7.0.130.0030.01315.43
7.0.120.0050.00515.32
7.0.110.0030.00615.58
7.0.100.0060.00615.59
7.0.90.0080.00415.35
7.0.80.0030.00615.63
7.0.70.0060.00615.62
7.0.60.0050.04017.61
7.0.50.0030.03816.68
7.0.40.0070.02616.81
7.0.30.0200.03216.95
7.0.20.0110.02316.90
7.0.10.0030.03616.66
7.0.00.0030.03516.93
5.6.400.0030.00914.71
5.6.390.0040.00714.67
5.6.380.0110.00314.18
5.6.370.0030.00714.17
5.6.360.0080.00614.21
5.6.350.0070.00714.66
5.6.340.0060.00314.37
5.6.330.0070.00414.18
5.6.320.0060.00613.97
5.6.310.0060.00614.37
5.6.300.0030.00514.06
5.6.290.0070.00714.52
5.6.280.0020.03317.90
5.6.270.0080.00414.19
5.6.260.0030.00614.31
5.6.250.0080.00314.80
5.6.240.0030.01014.39
5.6.230.0060.00614.29
5.6.220.0030.00614.38
5.6.210.0020.04617.44
5.6.200.0080.04516.30
5.6.190.0070.04817.54
5.6.180.0240.03717.35
5.6.170.0120.03517.50
5.6.160.0070.03717.63
5.6.150.0050.02316.37
5.6.140.0070.03316.50
5.6.130.0050.02916.51
5.6.120.0090.04717.70
5.6.110.0070.04217.91
5.6.100.0110.03817.72
5.6.90.0070.02517.84
5.6.80.0020.04917.30
5.6.70.0090.00614.16
5.6.60.0070.01014.42
5.6.50.0110.00414.31
5.6.40.0110.00314.29
5.6.30.0120.00314.33
5.6.20.0060.00614.16
5.6.10.0000.01014.19
5.6.00.0000.01314.43
5.5.380.0000.01214.42
5.5.370.0000.01314.60
5.5.360.0040.00814.25
5.5.350.0150.03617.35
5.5.340.0050.04616.13
5.5.330.0050.02517.30
5.5.320.0030.02617.29
5.5.310.0120.02517.31
5.5.300.0050.04516.17
5.5.290.0130.03816.17
5.5.280.0050.03617.52
5.5.270.0030.04817.84
5.5.260.0100.04617.61
5.5.250.0060.02217.49
5.5.240.0090.04017.17
5.5.230.0070.01014.34
5.5.220.0060.00914.41
5.5.210.0040.00714.37
5.5.200.0100.00614.20
5.5.190.0030.01014.02
5.5.180.0030.01014.38
5.5.170.0110.00414.41
5.5.160.0000.01414.02
5.5.150.0030.00914.60
5.5.140.0040.01114.40
5.5.130.0000.01214.43
5.5.120.0040.00814.05
5.5.110.0030.01014.45
5.5.100.0050.00514.31
5.5.90.0110.00314.23
5.5.80.0030.00614.50
5.5.70.0040.01114.36
5.5.60.0070.00714.00
5.5.50.0040.00414.27
5.5.40.0110.00414.47
5.5.30.0000.01714.36
5.5.20.0040.01414.46
5.5.10.0080.00814.29
5.5.00.0140.00313.82

preferences:
55.59 ms | 400 KiB | 5 Q