# include the library itself require_once dirname(dirname(__FILE__)) . '/php-iban.php'; # display registry contents #print_r($_iban_registry); # init $errors = 0; # Try to validate an invalid IBAN $iban = "(@#(*@*ZV-This is NOT an IBAN!"; if (verify_iban($iban)) { print "ERROR: An invalid IBAN was validated!\n"; $errors++; } print "Hooray! - Invalid IBAN successfully rejected.\n\n"; # Broken IIBAN $broken_iiban = 'AA12011123ZS6'; $suggestions = iban_mistranscription_suggestions($broken_iiban); if (count($suggestions)) { print "Hooray! Successfully derived '" . implode(',', $suggestions) . "' as likely transcription error source suggestion(s) for the incorrect IBAN {$broken_iiban}.\n"; } else { print "ERROR: Not able to ascertain suggested transcription error source(s) for {$broken_iiban}.\n"; } print "\n"; # Loop through the registry's examples, validating foreach ($_iban_registry as $country) { # get country code $countrycode = $country['country']; # start section print "[{$countrycode}: " . iban_country_get_country_name($countrycode) . "]\n"; # output remaining country properties print "Is a SEPA member? "; if (iban_country_is_sepa($countrycode)) {
$observed_length = strlen($iban); $expected_length = iban_country_get_iban_length($country); if ($observed_length != $expected_length) { print " (length {$observed_length} does not match expected length {$expected_length} for country {$country})"; } $checksum = iban_get_checksum_part($iban); if (!iban_verify_checksum($iban)) { print " (checksum {$checksum} invalid)"; } $regex = '/' . iban_country_get_iban_format_regex($country) . '/'; if (!preg_match($regex, $iban)) { print " (does not match regex {$regex} for country {$country})"; } #################################################### $errors++; $suggestions = iban_mistranscription_suggestions($iban); if (is_array($suggestions)) { if (count($suggestions) == 1) { print " (you meant '" . $suggestions[0] . "', right?)"; } elseif (count($suggestions) > 1) { print " (perhaps "; $done = 0; foreach ($suggestions as $suggestion) { if ($done > 0) { print ', or '; } print "'" . $suggestion . "'"; $done++; } print "?)"; }
public function MistranscriptionSuggestions() { return iban_mistranscription_suggestions($this->iban); }