3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PasswordValidation { public static function digitCount($string) { return self::occurrencesCount($string, '/[0-9]/'); } public static function lcCount($string) { return self::occurrencesCount($string, '/[a-z]/'); } public static function ucCount($string) { return self::occurrencesCount($string, '/[A-Z]/'); } public static function nonAlphaNumCount($string) { return self::occurrencesCount($string, '/[^0-9a-zA-Z]/'); } public static function repeatedCharCount($string) { $lcString = strtolower($string); $prevChar = $lcString[0]; $currentLen = 0; $maxLen = 0; for ($i = 1; $i < strlen($lcString); $i++) { if ($lcString[$i] === $prevChar) { $currentLen += 1; } else { $currentLen = 1; } $maxLen = max($maxLen, $currentLen); $prevChar = $lcString[$i]; } return $maxLen; } public static function consecutiveCharCount($string) { $lcString = strtolower($string); $prevChar = $lcString[0]; $currentLen = 0; $maxLen = 0; $ascending = null; for ($i = 1; $i < strlen($lcString); $i++) { $diff = ord($lcString[$i]) - ord($prevChar); if ($diff == 1) { if ($ascending !== true) { $ascending = true; $currentLen = 1; } $currentLen += 1; } elseif ($diff == -1) { if ($ascending !== false) { $ascending = false; $currentLen = 1; } $currentLen += 1; } else { $currentLen = 1; } $maxLen = max($maxLen, $currentLen); $prevChar = $lcString[$i]; } return $maxLen; } private static function occurrencesCount($string, $regex) { preg_match_all($regex, $string, $matches); return count($matches[0]); } } $string = "abcdefgA"; if (strlen($string) === PasswordValidation::consecutiveCharCount($string)) { echo "Password not allowed!"; }

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.01416.50
8.3.50.0110.00922.07
8.3.40.0140.00718.79
8.3.30.0100.01019.04
8.3.20.0000.00720.33
8.3.10.0090.00023.66
8.3.00.0040.00419.69
8.2.180.0150.00616.38
8.2.170.0070.01422.96
8.2.160.0110.00320.39
8.2.150.0060.00324.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0050.00319.23
8.2.110.0080.00319.27
8.2.100.0040.00817.78
8.2.90.0040.00420.42
8.2.80.0080.00019.34
8.2.70.0040.00417.50
8.2.60.0040.00417.63
8.2.50.0000.00818.05
8.2.40.0040.00417.91
8.2.30.0000.00719.55
8.2.20.0050.00217.73
8.2.10.0050.00218.13
8.2.00.0090.00017.68
8.1.280.0130.00725.92
8.1.270.0050.00323.96
8.1.260.0030.00626.35
8.1.250.0090.00028.09
8.1.240.0090.00022.55
8.1.230.0110.00020.80
8.1.220.0090.00017.74
8.1.210.0030.00518.78
8.1.200.0030.00717.23
8.1.190.0060.00317.25
8.1.180.0040.00418.10
8.1.170.0000.00817.62
8.1.160.0070.00018.94
8.1.150.0050.00318.50
8.1.140.0070.00017.46
8.1.130.0000.00717.80
8.1.120.0070.00017.44
8.1.110.0040.00717.35
8.1.100.0000.00717.46
8.1.90.0030.00517.45
8.1.80.0100.00017.45
8.1.70.0000.00817.46
8.1.60.0090.00317.64
8.1.50.0030.00517.56
8.1.40.0080.00017.56
8.1.30.0040.00417.56
8.1.20.0040.00417.69
8.1.10.0040.00417.62
8.1.00.0000.00717.50
8.0.300.0070.00019.89
8.0.290.0050.00516.58
8.0.280.0030.00318.43
8.0.270.0030.00317.21
8.0.260.0030.00317.13
8.0.250.0000.00616.87
8.0.240.0040.00416.79
8.0.230.0030.00416.86
8.0.220.0060.00016.71
8.0.210.0030.00316.81
8.0.200.0030.00316.94
8.0.190.0090.00016.84
8.0.180.0000.00716.82
8.0.170.0040.00416.88
8.0.160.0000.00816.85
8.0.150.0030.00616.70
8.0.140.0080.00016.68
8.0.130.0060.00013.25
8.0.120.0050.00316.64
8.0.110.0070.00016.73
8.0.100.0000.00716.79
8.0.90.0040.00416.71
8.0.80.0070.01416.83
8.0.70.0000.00716.70
8.0.60.0040.00416.78
8.0.50.0050.00216.88
8.0.30.0130.00617.16
8.0.20.0120.01117.40
8.0.10.0050.00217.04
8.0.00.0030.01416.80
7.4.330.0000.00515.09
7.4.320.0060.00316.50
7.4.300.0000.00616.65
7.4.290.0000.00716.36
7.4.280.0050.00316.51
7.4.270.0080.00016.66
7.4.260.0000.00816.50
7.4.250.0040.00416.36
7.4.240.0000.00716.57
7.4.230.0000.00716.25
7.4.220.0120.00616.63
7.4.210.0060.00916.49
7.4.200.0000.00716.68
7.4.160.0100.00616.47
7.4.150.0070.01317.40
7.4.140.0120.00817.86
7.4.130.0090.00916.42
7.4.120.0080.00916.64
7.4.110.0070.01416.50
7.4.100.0120.00616.59
7.4.90.0070.01316.44
7.4.80.0030.01619.39
7.4.70.0140.00516.47
7.4.60.0100.00616.45
7.4.50.0000.00616.33
7.4.40.0140.00716.45
7.4.30.0090.00616.45
7.4.00.0000.01815.04
7.3.330.0050.00013.30
7.3.320.0050.00013.24
7.3.310.0070.00016.22
7.3.300.0030.00316.24
7.3.290.0110.00316.32
7.3.280.0120.00616.42
7.3.270.0100.00717.40
7.3.260.0170.00316.32
7.3.250.0090.00816.45
7.3.240.0160.00616.57
7.3.230.0060.01216.44
7.3.210.0130.00316.55
7.3.200.0090.01019.39
7.3.190.0100.00716.32
7.3.180.0070.01016.48
7.3.170.0070.01016.53
7.3.160.0080.00816.29
7.3.120.0060.01214.80
7.2.330.0030.02016.51
7.2.320.0120.00316.55
7.2.310.0100.01016.52
7.2.300.0110.00516.88
7.2.290.0200.00316.80
7.2.110.0120.00816.68
7.2.100.0070.00716.66
7.2.90.0110.00516.69
7.2.80.0060.01116.83
7.2.70.0070.01116.98
7.2.60.0070.00716.90
7.2.50.0120.00417.14
7.2.40.0090.00616.86
7.2.30.0160.00316.93
7.2.20.0140.00316.88
7.2.10.0060.01016.88
7.2.00.0080.00318.09
7.1.230.0120.00615.73
7.1.220.0040.00815.71
7.1.210.0140.00015.96
7.1.200.0100.00415.64
7.1.190.0110.01115.77
7.1.180.0120.00515.80
7.1.170.0090.00415.68
7.1.160.0090.00515.55
7.1.150.0090.00615.89
7.1.140.0100.00515.91
7.1.130.0120.00315.63
7.1.120.0030.01115.63
7.1.110.0080.00815.79
7.1.100.0060.00916.98
7.1.90.0070.00715.84
7.1.80.0150.00015.54
7.1.70.0110.00316.46
7.1.60.0040.01317.84
7.1.50.0110.00816.43
7.1.40.0060.00916.00
7.1.30.0120.00316.04
7.1.20.0100.00715.84
7.1.10.0060.00315.85
7.1.00.0050.04119.00
7.0.310.0090.00315.17
7.0.300.0130.00315.36
7.0.290.0150.00015.56
7.0.280.0070.00715.20
7.0.270.0100.00215.61
7.0.260.0090.00315.26
7.0.250.0100.00315.23
7.0.240.0110.00515.46
7.0.230.0150.00415.21
7.0.220.0080.00315.30
7.0.210.0060.01015.41
7.0.200.0030.00916.21
7.0.190.0090.00315.17
7.0.180.0030.00615.45
7.0.170.0000.00815.55
7.0.160.0000.00815.56
7.0.150.0110.00015.54
7.0.140.0060.03618.74
7.0.130.0030.00715.56
7.0.120.0090.00615.50
7.0.110.0030.01015.25
7.0.100.0070.00715.42
7.0.90.0140.00015.42
7.0.80.0080.00315.31
7.0.70.0000.01415.16
7.0.60.0060.04117.61
7.0.50.0060.02316.71
7.0.40.0050.03716.81
7.0.30.0170.02916.90
7.0.20.0080.05116.70
7.0.10.0190.03316.66
7.0.00.0100.03716.78
5.6.380.0000.01414.56
5.6.370.0080.00814.30
5.6.360.0070.00514.04
5.6.350.0040.01214.30
5.6.340.0070.00714.23
5.6.330.0080.00514.17
5.6.320.0050.00814.54
5.6.310.0030.00714.30
5.6.300.0080.00814.37
5.6.290.0000.00814.39
5.6.280.0070.03817.61
5.6.270.0000.01114.29
5.6.260.0040.00714.27
5.6.250.0030.00714.45
5.6.240.0060.00614.30
5.6.230.0030.00714.38
5.6.220.0080.00414.27
5.6.210.0050.02717.43
5.6.200.0070.03416.39
5.6.190.0000.04417.41
5.6.180.0000.02517.64
5.6.170.0150.04217.37
5.6.160.0050.02517.22
5.6.150.0100.03816.32
5.6.140.0050.02716.27
5.6.130.0040.03716.30
5.6.120.0010.02617.78
5.6.110.0100.03717.59
5.6.100.0080.04217.61
5.6.90.0010.05117.64
5.6.80.0080.04117.52
5.6.70.2320.02717.18
5.6.60.0070.00714.45
5.6.50.0070.00314.18
5.6.40.0140.00013.99
5.6.30.0080.00413.99
5.6.20.0040.00814.08
5.6.10.0040.00714.47
5.6.00.0030.01014.65
5.5.380.0000.00612.79
5.5.370.0050.00312.79
5.5.360.0000.00812.79
5.5.350.0050.04416.58
5.5.340.0030.02115.40
5.5.330.0030.04316.46
5.5.320.0200.03516.54
5.5.310.0210.01816.51
5.5.300.0050.04315.38
5.5.290.0090.03415.44
5.5.280.0080.02816.89
5.5.270.0140.03516.79
5.5.260.0060.04216.89
5.5.250.0000.04716.72
5.5.240.0080.04016.50
5.5.230.0050.00012.79
5.5.220.0050.00312.79
5.5.210.0030.00312.79
5.5.200.0030.00312.79
5.5.190.0060.00312.79
5.5.180.0030.00312.79
5.5.170.0070.00414.36
5.5.160.0060.00012.79
5.5.150.0050.00212.79
5.5.140.0040.00712.79
5.5.130.0050.00012.79
5.5.120.0000.01212.79
5.5.110.0000.01212.79
5.5.100.0030.00612.79
5.5.90.0110.00012.79
5.5.80.0040.00812.79
5.5.70.0060.00012.79
5.5.60.0050.00312.79
5.5.50.0030.00512.79
5.5.40.0040.00412.79
5.5.30.0030.00512.79
5.5.20.0000.00812.79
5.5.10.0050.00312.79
5.5.00.0030.00312.79
5.4.450.0270.02228.33
5.4.440.0220.02628.29
5.4.430.0150.02428.28
5.4.420.0220.02328.28
5.4.410.0120.02228.28
5.4.400.0310.02828.27
5.4.390.0140.02128.26
5.4.380.0110.02615.64
5.4.370.0140.02515.77
5.4.360.0110.03015.76
5.4.350.0110.02815.74
5.4.340.0080.03015.65
5.4.330.0000.00712.79
5.4.320.0020.02312.65
5.4.310.0030.02212.65
5.4.300.0020.02312.65
5.4.290.0080.02112.65
5.4.280.0050.02112.60
5.4.270.0040.02612.60
5.4.260.0050.02212.60
5.4.250.0050.01912.60
5.4.240.0040.02212.60
5.4.230.0050.02212.60
5.4.220.0090.01912.60
5.4.210.0060.02112.59
5.4.200.0070.01912.60
5.4.190.0030.02212.59
5.4.180.0030.02212.60
5.4.170.0040.02512.60
5.4.160.0040.02512.60
5.4.150.0040.02512.60
5.4.140.0060.02012.44
5.4.130.0070.02212.43
5.4.120.0010.02312.41
5.4.110.0080.02112.41
5.4.100.0060.02112.41
5.4.90.0090.01512.41
5.4.80.0050.02012.41
5.4.70.0050.02012.40
5.4.60.0040.02012.41
5.4.50.0080.02212.40
5.4.40.0010.02312.40
5.4.30.0050.02412.40
5.4.20.0040.02012.40
5.4.10.0060.02012.40
5.4.00.0030.02212.14
5.3.290.0040.02212.79
5.3.280.0040.02112.75
5.3.270.0070.02012.76
5.3.260.0040.02312.76
5.3.250.0070.01812.76
5.3.240.0060.02112.76
5.3.230.0060.02312.75
5.3.220.0050.02212.74
5.3.210.0060.02112.73
5.3.200.0060.01712.74
5.3.190.0070.02412.73
5.3.180.0060.02612.73
5.3.170.0050.02212.73
5.3.160.0050.02112.73
5.3.150.0020.02312.73
5.3.140.0060.02212.73
5.3.130.0050.02212.72
5.3.120.0050.02312.72
5.3.110.0060.02012.72
5.3.100.0040.02212.46
5.3.90.0020.02212.45
5.3.80.0060.02012.45
5.3.70.0040.02412.45
5.3.60.0020.02312.44
5.3.50.0030.02312.41
5.3.40.0030.02212.42
5.3.30.0070.02012.39
5.3.20.0050.01812.28
5.3.10.0070.02212.27
5.3.00.0040.02012.26
5.2.170.0040.01811.02
5.2.160.0070.01611.02
5.2.150.0020.02411.02
5.2.140.0060.01611.01
5.2.130.0050.01510.99
5.2.120.0050.01411.00
5.2.110.0040.01711.00
5.2.100.0040.01810.99
5.2.90.0020.01910.99
5.2.80.0040.01810.99
5.2.70.0040.02210.99
5.2.60.0040.02010.97
5.2.50.0050.01810.95
5.2.40.0020.01710.94
5.2.30.0040.02110.93
5.2.20.0040.01710.93
5.2.10.0080.01210.88
5.2.00.0040.01610.81
5.1.60.0010.01610.45
5.1.50.0030.01510.45
5.1.40.0040.01210.44
5.1.30.0040.01610.61
5.1.20.0050.01510.63
5.1.10.0040.01410.49
5.1.00.0060.01410.49
5.0.50.0040.0119.73
5.0.40.0040.0159.67
5.0.30.0040.0179.57
5.0.20.0040.0129.55
5.0.10.0040.0119.54
5.0.00.0040.0179.54
4.4.90.0030.0118.79
4.4.80.0020.0108.77
4.4.70.0020.0098.77
4.4.60.0030.0098.77
4.4.50.0040.0098.78
4.4.40.0030.0148.75
4.4.30.0020.0098.77
4.4.20.0030.0128.82
4.4.10.0020.0098.82
4.4.00.0020.0168.78
4.3.110.0040.0108.73
4.3.100.0030.0078.73
4.3.90.0020.0108.71
4.3.80.0050.0138.69
4.3.70.0020.0108.71
4.3.60.0030.0098.71
4.3.50.0030.0098.71
4.3.40.0040.0138.66
4.3.30.0040.0098.04
4.3.20.0010.0108.03
4.3.10.0010.0118.01
4.3.00.0050.00525.14

preferences:
48.41 ms | 401 KiB | 5 Q