PHP code example of ondrakub / bank-php

1. Go to this page and download the library: Download ondrakub/bank-php 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/ */

    

ondrakub / bank-php example snippets


try {

	echo Bank::getName(3030);

} catch (BankException $e) {
	echo 'Error: '. $e->getMessage();
}


try {

	$codes = Bank::getCodes('bank');

	foreach ($codes as $key => $value) {
		echo $key . ' - '. $value . '<br>';
	}

} catch (BankException $e) {
	echo 'Error: '. $e->getMessage();
}

try {

	//accept xx-xx/xxxx, xx/xxxx, 00-xx/xxxx
	$bank = new Bank('1135595026/3030');

	echo 'account number: ' . $bank->getAccount() . '<br>';
	echo 'full account number: ' . $bank->getAccount(Bank::ZERO) . '<br>';
	echo 'prefix: ' . $bank->getPrefix() . '<br>';
	echo 'prefix with zero: ' . $bank->getPrefix(Bank::ZERO) . '<br>';
	echo 'number: ' . $bank->getNumber() . '<br>';
	echo 'number with zero: ' . $bank->getNumber(Bank::ZERO) . '<br>';
	echo 'code: ' . $bank->getCode() . '<br>';
	echo 'valid account: ' . $bank->isValid() . '<br>';
	echo 'IBAN: ' . $bank->getIban() . '<br>';
	echo 'formatted IBAN: ' . $bank->getIban(Bank::FORMATTED) . '<br>';
	echo 'BIC code (SWIFT): ' . $bank->getBic();

} catch (BankException $e) {
	echo 'Error: '. $e->getMessage();
}


php composer.phar