IBAN::Verify PHP Method

Verify() public method

public Verify ( $iban = '', $machine_format_only = false )
    public function Verify($iban = '', $machine_format_only = false)
    {
        if ($iban != '') {
            return verify_iban($iban, $machine_format_only);
        }
        return verify_iban($this->iban, $machine_format_only);
        # we could throw exceptions of various types, but why - does it really
        # add anything? possibly some slightly better user feedback potential.
        # however, this can be written by hand by performing individual checks
        # ala the code in verify_iban() itself where required, which is likely
        # almost never. for the increased complexity and
        # maintenance/documentation cost, i say, therefore: no. no exceptions.
    }

Usage Example

Ejemplo n.º 1
0
 # get example iban
 $myIban = new IBAN($myCountry->IBANExample());
 # output example iban properties one by one
 print "Example IBAN: " . $myIban->HumanFormat() . "\n";
 print " - country  " . $myIban->Country() . "\n";
 print " - checksum " . $myIban->Checksum() . "\n";
 print " - bban     " . $myIban->BBAN() . "\n";
 print " - bank     " . $myIban->Bank() . "\n";
 print " - branch   " . $myIban->Branch() . "\n";
 print " - account  " . $myIban->Account() . "\n";
 # output all properties
 #$parts = $myIban->Parts();
 #print_r($parts);
 # verify
 print "\nChecking validity... ";
 if ($myIban->Verify()) {
     print "IBAN {$myIban->iban} is valid.\n";
 } else {
     print "ERROR: IBAN {$myIban->iban} is invalid.\n";
     $correct = $myIban->SetChecksum();
     if ($correct == $iban) {
         print "       (checksum is correct, structure must have issues.)\n";
         $machine_iban = $myIban->MachineFormat();
         print "        (machine format is: '{$machine_iban}')\n";
         $country = $myIban->Country();
         print "        (country is: '{$country}')\n";
         $myCountry = new IBANCountry($country);
         if (strlen($machine_iban) != $myCountry->IBANLength()) {
             print "        (ERROR: length of '" . strlen($machine_iban) . "' does not match expected length for country's IBAN '" . $myCountry->IBANLength() . "'.)";
         }
         $regex = '/' . $myCountry->IBANFormatRegex() . '/';
All Usage Examples Of IBAN::Verify