PHP code example of ixnode / php-iban

1. Go to this page and download the library: Download ixnode/php-iban library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ixnode / php-iban example snippets


use Ixnode\PhpIban\Iban;
use Ixnode\PhpIban\Validator;

...

$iban = 'DE02120300000000202051';
$validator = new Validator(new Iban($iban));

print $validator->isValid() ? 'YES' : 'NO';
// (string) YES

print $validator->getAccount()->getAccountNumber();
// (string) 0000202051

print $validator->getIban()->getIbanFormatted();
// (string) DE02 1203 0000 0000 2020 51

etc.

use Ixnode\PhpIban\Account;

...

$accountNumber = '0000202051';
$bankCode = '12030000';
$countryCode = 'DE';
$account = new Account($accountNumber, $bankCode, $countryCode);

print $account->getIban();
// (string) DE02120300000000202051

print $account->getIbanFormatted();
// (string) DE02 1203 0000 0000 2020 51

use Ixnode\PhpIban\Account;
use Ixnode\PhpIban\Constant\IbanFormats;

...

$accountNumber = '00020053701';
$bankCode = '30027';
$countryCode = 'FR';
$branchCode = '17533';
$nationalCheckDigits = '59';
$account = new Account($accountNumber, $bankCode, $countryCode, [
    IbanFormat::KEY_BRANCH_CODE => $branchCode,
    IbanFormat::KEY_NATIONAL_CHECK_DIGITS => $nationalCheckDigits,
]);

print $account->getIban();
// (string) FR7630027175330002005370159

print $account->getIbanFormatted();
// (string) FR76 3002 7175 3300 0200 5370 159
bash
composer 
bash
vendor/bin/php-iban -V
bash
0.1.0 (2023-09-01 21:09:52) - Björn Hempel <[email protected]>
bash
vendor/bin/php-iban account-number:validate 0000202051 12030000
bash
git clone [email protected]:ixnode/php-iban.git && cd php-iban