3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NIP { private const WEIGHTS = [6, 5, 7, 2, 3, 4, 5, 6, 7]; private const NIP_MODULO = 11; private const INVALID_CHECKSUM = 10; public static function validate(string $nip): bool { $value = preg_replace('/[\s-]/', '', $nip); if ('0000000000' === $value || !preg_match('/^\d{10}$/', $value)) { return false; } $checkSum = self::getChecksum($value); if (self::INVALID_CHECKSUM === $checkSum || $checkSum !== ((int) (substr($value, -1)))) { return false; } return true; } private static function getChecksum(string $nip): int { $sum = 0; foreach (self::WEIGHTS as $key => $weight) { $sum += $weight * ((int) $nip[$key]); } return $sum % self::NIP_MODULO; } } $nip_numbers = array( "1234567890", "5366239267", "1071206063", "1160045242", "8123035307", "5361869035", "9322423343", "1191232175", "1079704010", "1560650337" ); $c = new NIP(); foreach ($nip_numbers as $a) { var_dump($c->validate($a)); }

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.0090.01219.83
8.4.10.0100.00019.51
8.3.150.0120.00616.97
8.3.140.0130.00616.69
8.3.130.0180.00316.79
8.3.120.0300.01316.90
8.3.110.0300.01216.73
8.3.100.0380.01516.54
8.3.90.0360.01116.45
8.3.80.0400.00316.29
8.3.70.0290.01416.35
8.3.60.0290.01616.42
8.3.50.0300.00916.38
8.3.40.0330.00817.14
8.3.30.0330.00017.48
8.3.20.0230.01417.54
8.3.10.0210.01417.56
8.3.00.0110.01119.35
8.2.260.0110.00717.14
8.2.250.0130.00916.60
8.2.240.0290.00916.57
8.2.230.0310.00916.48
8.2.220.0260.01516.52
8.2.210.0330.00716.51
8.2.200.0340.00616.39
8.2.190.0260.01516.26
8.2.180.0420.00416.56
8.2.170.0380.00817.52
8.2.160.0290.01217.63
8.2.150.0360.00617.63
8.2.140.0280.01417.41
8.2.130.0350.00617.64
8.2.120.0270.01517.51
8.2.110.0340.00917.75
8.2.100.0380.00317.83
8.2.90.0330.00917.64
8.2.80.0340.00717.66
8.2.70.0250.01817.33
8.2.60.0330.01517.67
8.2.50.0270.01217.72
8.2.40.0300.00817.75
8.2.30.0240.01417.56
8.2.20.0410.00317.47
8.2.10.0280.00917.44
8.2.00.0260.00717.46
8.1.310.0030.01018.31
8.1.300.0290.01115.91
8.1.290.0290.01215.97
8.1.280.0300.00916.53
8.1.270.0360.00617.53
8.1.260.0370.00417.28
8.1.250.0330.00717.47
8.1.240.0260.01017.46
8.1.230.0250.01117.36
8.1.220.0260.00717.57
8.1.210.0360.01017.16
8.1.200.0340.00916.96
8.1.190.0300.01117.22
8.1.180.0330.00417.14
8.1.170.0340.00417.30
8.1.160.0350.00417.43
8.1.150.0250.00917.42
8.1.140.0230.00717.09
8.1.130.0200.01617.60
8.1.120.0320.00617.54
8.1.110.0330.00317.37
8.1.100.0390.00017.17
8.1.90.0190.01917.25
8.1.80.0370.00017.35
8.1.70.0380.00617.00
8.1.60.0400.00617.56
8.1.50.0270.00617.46
8.1.40.0290.00617.23
8.1.30.0300.00717.34
8.1.20.0320.00717.56
8.1.10.0280.01217.50
8.1.00.0340.00717.38

preferences:
33.72 ms | 403 KiB | 5 Q