php-iban是一個用 PHP 解析、驗證和產生 IBAN(和 IIBAN)銀行帳戶資訊的函式庫。
可以檢索 IBAN 的所有部分,包括國家代碼、校驗和、BBAN、金融機構或銀行代碼、帳號,以及在使用固定長度國家系統的情況下,也可以檢索分行/分類代碼。如果可用,還可以檢索、驗證和正確設定舊版國家校驗和,無論它們適用於帳號部分、銀行和分行識別碼、上述部分或全部。 IBAN國家代碼可以轉換為ISO3166-1 alpha-2和IANA格式,可以查詢作為附屬領土註冊機構的母IBAN國家、官方國家貨幣(ISO4217 alpha代碼格式)、中央銀行名稱和中央銀行URL也可以查詢以簡化集成。 IBAN 可以在人類和機器表示之間進行轉換。在特殊情況下(例如親屬識別),IBAN 可能會被混淆以呈現給人類。包含來自不同國家的範例/測試 IBAN 資料庫。最後,當檢測到由於轉錄錯誤而導致的不正確 IBAN 時,可以對最初預期的輸入提出高度準確的建議。
此解析器是使用正規表示式建構的,以適應 SWIFT 提供的官方IBAN 註冊表的內容,然後針對特殊情況(例如 SWIFT 官方規範中的錯誤和遺漏)進行手動修改。
最初改編中的各種缺陷已經得到糾正,當前版本應該是一個相當正確和可靠的實現。
在適當的情況下,歐洲銀行標準委員會(ECBS) 的建議也已納入其中。
請記住,由於規範經常更改,如果最近發布了新版本,它可能不是 100% 最新的 - 但我會盡力而為。目前我們認為已更新到 2020 年 1 月的版本,即。 PDF 版本#86。
它已獲得 LGPL 許可,可在商業環境中免費使用。
支援以下 116 個官方和非官方IBAN 國家。
如果您使用 Composer,您只需執行composer require globalcitizen/php-iban即可開始。據報道(和)是透過作曲家完成的。
(如果您還沒有composer並且希望以不安全的方式安裝它(不推薦,但方便),您可以運行curl -sS https://getcomposer.org/installer | php或wget -O- https://getcomposer.org/installer | php )
然後只需將以下內容添加到您的composer.json檔案中:
// composer.json
{
"require" : {
"globalcitizen/php-iban" : "4.2.3"
}
}然後,您可以透過從composer.json檔案所在的目錄執行composer的更新命令來安裝新的依賴項:
# install
$ php composer.phar install
# update
$ php composer.phar update globalcitizen/php-iban
# or you can simply execute composer command if you set it to
# your PATH environment variable
$ composer install
$ composer update globalcitizen/php-iban你可以在 Packagist 上看到這個函式庫。
對於常規安裝,請使用git clone命令:
# HTTP
$ git clone https://github.com/globalcitizen/php-iban.git
# SSH
$ git clone [email protected]:globalcitizen/php-iban.git或者,將php-iban庫嵌入到您自己的git管理的儲存庫中的特定修訂號中,以便可以以可預測的方式更新版本,同時維護依賴其功能的更大系統:
# enter your project's git repo
$ cd my-existing-project-with-a-git-repo/
# select an appropriate place to create the php-iban subdir
$ cd lib/
# add php-iban as a submodule
$ git submodule add https://github.com/globalcitizen/php-iban.git
# commit new submodule
$ git commit -m ' Add php-iban submodule '然後,當第一次檢查帶有子模組的git項目時,通常您需要執行幾個額外的步驟:
# check out your project as normal
$ git clone [email protected]:your/project.git
# initialize submodules
$ git submodule init
# update submodules
$ git submodule update若要跳過這些步驟,請在簽出時向git clone新增--recursive參數:
# check out your project, initialize and update all submodules
$ git clone --recursive [email protected]:your/project.git如果您稍後希望您的專案使用更新版本的php-iban ,請執行:
# fetch changes
$ git submodule update --remote php-iban
# commit
$ git commit -m ' Update php-iban submodule ' zip或tar.gz格式的最新版本。unzip filename.zip 。libraries/php-iban中包含php-iban ,您可以使用下列 require_once() 語句: <?php
require_once ( dirname ( __FILE__ ) . ' /../libraries/php-iban/php-iban.php ' );
# ... your code utilizing php-iban
?> 下表根據一般專案資訊和支援的程式設計範例,將php-iban與提供 IBAN 相關功能的其他 PHP 專案進行了比較。
| 專案 | 利克。 | 流程 | 物件導向 | 開始 | 最新的 | 星星 | 手錶 | 叉 | 安裝量 | 家居文化 | 部門 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| php-iban | LGPL | ✔ | ✔ | 2009年 | 4.2.3 | 第426章 | 29 | 104 | 〜7M+* | 全球的* | 沒有任何 |
| 伊班語 | 麻省理工學院 | ✘ | ✔ | 2013年 | 1.3.0 | 50 | 9 | 19 號 | 178.39k | 德文 | 地段 |
| ISO代碼 | 通用公共授權3 | ✘ | ✔ | 2012年 | 2.1.1 | 第466章 | 22 | 54 | 145k | 法語 | 地段 |
| SepaUtil 的 | 通用公共授權3 | ✘ | ✔ | 2014年 | 1.2.3 | 8 | 4 | 3 | 25k | 德文 | php單元 |
| 交響樂團 | 麻省理工學院 | ✘ | ✔ | 2013年 | 3.3.6 | 15k | 1214 | 5.6k | 23M+ | 法語 | 地段 |
筆記:
現在讓我們來看看功能。
| + | 國際標準化組織 | 網路號碼分配機構 | 國家環境保護局 | ₶ | 尿素酶 | 公噸 | 數控 | ₴ | CB | 哈? | 登記處 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| php-iban | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 116:具有開源工具鍊和文件的完整、錯誤更正的 CSV |
| 伊班語 | ✔* | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | 54:部分、硬編碼、來源可疑 |
| ISO代碼 | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | 66:部分、硬編碼、來源可疑 |
| SepaUtil 的 | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | 89:部分、硬編碼、來源可疑 |
| 交響樂團 | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | 95:部分、硬編碼、來源可疑 |
筆記:
IBAN XXXX XXXX XXXX XXXX而不是XXXXXXXXXXXXXXXX - 更合理。簡而言之,雖然Composer 用戶顯然傾向於使用競爭對手的庫(尤其是Iban),可能是由於我們整合Composer 檔案所花費的時間,但這些庫通常要么是成熟的Web 框架,要么依賴項繁重、不夠成熟、失敗向自由軟體基金會致敬,不支持過程式設計範式(因為 AbstractProductClassMakerFactories 無法滿足要求),使用來自可疑來源的數據,傾向於使用與某些商業用途不相容的許可證,並且坦率地說缺乏功能。
所以,無所畏懼的用戶......選擇 php-iban :用於 IBAN 和 IIBAN 處理的道德、功能、前瞻性、低麻煩的庫。選擇勝利! ;)
如果您從官方來源知道國家 IBAN、BBAN 或國家校驗和文件的 URL,請透過第 39 期和第 41 期告知我們。
法羅群島(FO) 的銀行沒有回應,將我轉介給他們的丹麥國家銀行也沒有回應。
盧森堡(LU) 似乎不符合任何單一校驗和系統。雖然有些 IBAN 確實使用相當常見的系統進行驗證,但其他系統則不使用或使用其他系統。關於盧森堡擁有國家校驗和系統的建議實際上可能是不正確的。我們需要在這裡進行一些澄清,希望有人能找到官方聲明。
茅利塔尼亞(MR) 有雙字元校驗和系統,但我們的範例 IBAN 與預期系統 MOD97-10 不符。以前,此處的 IBAN 始終固定為「13」校驗和數字,但從註冊表 v66 開始,它現在是動態的,這表明校驗和系統已更改或至少現在在全國範圍內放鬆。
如果您願意花一些時間搜索,我們可以為大多數國家/地區(尤其是較小的國家/地區)提供更多測試 IBAN...
4.2.3版本已經發布。
4.2.2版本已經發布。
4.2.1版本已經發布。
4.2.0版本已經發布。
4.1.1版本已經發布。
4.1.0版本已經發布。
4.0.0版本已經發布。
3.0.3版本已經發布。
3.0.2版本已經發布。
3.0.0版本已經發布。
2.8.2版本已經發布。
2.8.1版本已經發布。
TL BBAN 格式正規表示式刪除了無關空格(不影響 IBAN 驗證)。 (感謝@DanyCorbineauBappli) 2.8.0版本已經發布。
2.7.5版本已經發布。
2.7.4版本已經發布。
iban_to_obfsucated_format()或ObfuscatedFormat()用於針對特定輸出場景(例如相對識別)混淆 IBAN2.7.3版本已經發布。
2.7.2版本已經發布。
2.7.1版本已經發布。
2.7.0版本已經發布。
2.6.9版本已經發布。
SM ) 的國家校驗和實施2.6.8版本已經發布。
IT ) 的國家校驗和實施2.6.7版本已經發布。
SK ) 的國家校驗和實施2.6.6版本已經發布。
ini_set的環境中產生大量錯誤的問題2.6.5版本已經發布。
gmp擴充時的虛假警告2.6.4版本已經發布。
bcmath擴充的虛假依賴2.6.3版本已經發布。
2.6.2版本已經發布。
2.6.1版本已經發布。
2.6.0版本已經發布。
2.5.9版本已經發布。
2.5.8版本已經發布。
2.5.7版本已經發布。
2.5.6版本已經發布。
2.5.5版本已經發布。
2.5.4版本已經發布。
2.5.3版本已經發布。
2.5.2版本已經發布。
2.5.1版本已經發布。
908 ) 銀行似乎有多個即時 IBAN,其國家校驗和已損壞,因此我們忽略該銀行帳戶上的所有國家校驗和。2.5.0版本已經發布。
INGB (ING 銀行)的例外情況01 (斯洛維尼亞銀行)的例外情況utils/example-ibans下也維護一個測試 IBAN 函式庫,其中已經包含了許多國家/地區的大量條目。這應該會簡化未來的研究。2.4.20版本已經發布。
2.4.19版本已經發布。
2.4.18版本已經發布。
2.4.17版本已經發布。
01 )不實施國家校驗和計劃。斯洛維尼亞國家校驗和實施增加了一個例外。2.4.16版本已經發布。
2.4.15版本已經發布。
2.4.14版本已經發布。
2.4.13版本已經發布。
iban_mistranscription_suggestions()可以正確運行_verhoeff()現在在傳遞無效輸入時可以正確運行2.4.12版本已經發布。
2.4.11版本已經發布。
central_bank_url和central_bank_name查詢每個國家的中央銀行名稱和URL,例如:2.4.10版本已經發布。
currency_iso4217以ISO4217字母代碼格式儲存該國家/地區的官方貨幣,例如:2.4.9版本已經發布。
parent_registrar儲存IBAN國家/地區的父註冊商IBAN國家/地區,例如:2.4.8版本已經發布。
2.4.7版本已經發布。
2.4.6版本已經發布。
2.4.5版本已經發布。
2.4.4版本已經發布。
2.4.3版本已經發布。
2.4.2版本已經發布。
2.4.1版本已經發布。
2.4.0版本已經發布。
iban_{set|find|verify}_nationalchecksum()及其OO 包裝器等效項來確定、驗證和設定某些提供IBAN 之前國家校驗和演算法的國家/地區的正確國家校驗和。目前支援比利時 (BE)、法國 (FR) 和西班牙 (ES)。如果您希望您所在的國家/地區獲得支持,請參閱問題 #39 和問題 #41。 2.3.1版本已經發布。
2.3.0版本已經發布。
2.2.0版本已經發布。
2.1.9版本已經發布。
2.1.8版本已經發布。
2.1.7版本已經發布。
iban_get_nationalchecksum_part() 、 iban_country_get_nationalchecksum_start_offset()和iban_country_get_nationalchecksum_stop_offset()及其 OO 包裝等效項$myIban-> $myCountry->NationalChecksumStartOffset()及其 OO 包裝等效項$myIban->NationalChecksum() $mycountry->NationalChecksumStopOffset() () 、 $pffm-Nff>測試和文件已更新。如果您了解有關國家校驗和演算法的任何信息,請在第 39 期中提供協助。2.1.6版本已經發布。
machine_format_only驗證更新了 OO 包裝器和文件。2.1.5版本已經發布。
verify_iban()的附加嚴格machine_format_only模式可解決問題 #22。2.1.4版本已經發布。
2.1.3版本已經發布。
iban_to_human_format()的行為已修復。2.1.2版本已經發布。所有已知的非官方 IBAN 國家/地區代碼現已整合。除了較小的文檔更新和科索沃報告名稱的縮寫外,此版本還添加了:
2.1.1版本已經發布。目前,非官方的 IBAN 國家代碼正在整合,並且該過程仍在進行中。這個版本增加了:
2.1.0版本已經發布。
目前,非官方的 IBAN 國家代碼正在整合,並且該過程仍在進行中。創建了一個新標誌來檢查某個國家/地區是否是 SWIFT 發布的官方記錄。因此新增了以下新國家。
另請注意,IIBAN (AA) 記錄已標記為非官方,並且docs/TODO中列出的功能已遷移到 Github issues 並已刪除該檔案。
2.0.1版本已經發布。這是為了慶祝真正的測試、作曲家的支持以及最終趕上變化。此版本應與目前所有註冊表變更保持同步,包括對國家/地區的變更或新增:
1.6.0版本已經發布。此版本具有更多註冊表更正(新添加的區域有錯誤資料、範例 IBAN 中的錯誤校驗和等)以及增強的測試例程、擴展的文檔和更正的文檔。建議所有用戶升級。我們現在使用 Travis CI 自動執行測試腳本,為所有提交的程式碼提供額外的穩健性。這花了比預期更長的時間,因為不幸的是我選擇了Travis 破壞他們的構建日誌的確切時間- https://www.traviscistatus.com/incidents/fcllblkclgmb - 看看所有的大驚小怪是什麼.. ....再次證明雲端運算只是非常適合意外地破壞東西。因為他們想隱藏一些東西,所以實際上沒有任何調試輸出,我被引導相信這是我的錯。各位程式設計師,看哪:這是神秘失敗時代的黎明。
1.5.0版本已經發布。沒有程式碼更改,但我們現在有了 http://packagist.org/ 集成,希望這會觸發它開始工作。如果您使用 packagist,您現在只需執行composer require globalcitizen/php-iban即可將庫添加到您的專案中(感謝@acoulton 指明方向)
版本 1.4.9已使用基於 Github 的新發布流程發布。希望這為那些將庫與其他軟體捆綁在一起的人提供了一個堅實的錨點。我們還有一個貢獻的作曲家元資料檔來簡化整合。整合了新的 IBAN 註冊表 URL。刪除了舊的 SVN 標籤/主幹結構。
將 SWIFT URL 修正為 IBAN 頁面。強調轉錄錯誤錯誤的支持。
最後,Google已經關閉了code.google.com ,我們已經遷移到 Github了!一旦舊的trunk / tag結構(來自svn的殘留)被清理並且該文件從舊的 wiki 格式轉換為 Markdown,就會發布新版本。
1.4.6版本已經發布:
不幸的是,Google 現在要求code.google.com專案才能使用 Google Drive。我嘗試使用Google Drive(註冊一個新帳戶,跳過電子郵件圈子,被當作機器人對待,學習愚蠢的新的敏感友好介面,收到毫無意義的錯誤訊息,例如「您的共享限制已被超出」(與我被告知要在新帳戶上建立 2x290KB 檔案),然後完全失去了耐心。
因此,目前您只需使用git下載即可。我很快就會將php-iban遷移到 Github。 Google最近真是讓人頭疼,所有這些Google+和Google Drive垃圾,毀掉了Picasa,毀掉了Sketchup,等等。
1.4.5版本已經發布:
1.4.4版本已經發布:
專案原始碼儲存庫已從svn (呃)切換到git (耶!) 。
1.4.3版本已經發布:
docs/COMEDY-OF-ERRORS中的文檔,又作為註冊轉換器內聯的文檔。1.4.2版本已經發布:
1.4.1版本已經發布:
$__disable_iiban_gmp_extension=true; )1.4.1 版本仍在準備中,消除了一些錯誤並更新了註冊表…同時,我注意到我們已經在 Code Candy 部落格中得到了推薦! http://www.codecandies.com/2012/05/30/no-exceptions/ 德國人的幽默感萬歲!哈哈。
1.4.0版本已經發布:
VERSION文件,以根據請求在來源樹中包含硬版本資訊。 1.3.9版本已經發布:
1.3.8版本已經發布:
1.3.7版本已經發布:
1.3.6版本已經發布:
1.3.5版本已經發布:
1.3.4版本已經發布:
1.3.3版本已經發布:
1.3.2版本已經發布:
1.3.1版本已經發布:
1.3.0版本已經發布。此版本新增了轉錄錯誤錯誤建議支援。
1.2.0版本已經發布。根據目前的 IIBAN 互聯網草案,此版本添加了互聯網國際銀行帳號 (IIBAN) 支持,網址為 http://tools.ietf.org/html/draft-iiban-01
1.1.2版本已經發布。這會向主庫檔案新增長開啟標籤,以簡化許多預設 PHP 安裝上的部署。
1.1.1版本已經發布。這修復了新 OO 包裝器中函數呼叫中的拼字錯誤。非OO用戶不需要升級。
1.1.0版本已經發布。此版本新增了物件導向的包裝庫以及文件和測試腳本的相關更新。對於現有用戶來說,升級並不重要。
1.0.0版本已經發布。此版本包括以下變更:
iban_country_is_sepa($iban_country)iban_to_human_format($iban)將機器格式 IBAN 轉換為人類格式的佔位符支援(只需每四個字元添加一個空格)本月早些時候...小型維護版本,並不重要。
*我們現在有一個 http://groups.google.com/group/php-iban-users 郵件清單。請隨時發布您的反饋、疑問或建議 - 我們很想知道您如何使用該庫。迄今為止,該專案的下載量已超過 400 次,並且仍然強勁,每天都有超過 1 個新用戶 - 對於專業圖書館來說,這是一個相當不錯的表現!
*版本 12已發布。註冊表文件已改進,部分原因是用戶報告的結果,部分原因是在針對版本 11 執行自動化測試時發現的問題。
更正標題行標題中未顯示兩列( bban_length和iban_length )。現在它們已被添加。
對法國領土 (PF、TF、YT、NC、PM、WF) 註冊表項的修復法國領土未明確包含在 SWIFT 規範文本文件中。根據針對該條目的非結構化評論,它們是從法國複製的。然後,出於說明目的,透過簡單地修改國家/地區前綴而不重新產生校驗和來製作範例 IBAN。這些地區包含的 IBAN 範例現在應該是正確的。
直布羅陀和匈牙利(GI,HU) 修正了兩個地區在初始文件轉換後的正規表示式中附加了多餘的冒號的錯誤,該錯誤導致這些國家/地區的所有 IBAN 驗證失敗。
毛里求斯(MU) 將 IBAN 長度預期從 31 更正為 30。
瑞典(SE) 範例 IBAN 已在開發早期根據 IBAN 規範範例進行了手動修改,並且未通過校驗和。 IBAN 官方範例已恢復。
突尼斯(TN) 修正了初始文件轉換(IBAN 格式說明符到正規表示式轉換函數)中的錯誤所導致的不正確驗證字串。
require_once ( ' php-iban.php ' );
# ... your code utilising IBAN functions... # Verify an IBAN number.
# An optional second argument specifies $machine_format_only (default is false)
# If true, the function will not tolerate unclean inputs
# (eg. spaces, dashes, leading 'IBAN ' or 'IIBAN ', lower case)
# If false (default), input can be in either:
# - printed ('IIBAN xx xx xx...' or 'IBAN xx xx xx...'); or
# - machine ('xxxxx')
# ... string formats.
# Returns true or false.
if (! verify_iban ( $ iban , $ machine_format_only = false )) {
# ...
}
# Check the checksum of an IBAN - code modified from Validate_Finance PEAR class
if (! iban_verify_checksum ( $ iban )) {
# ...
}
# Suggest what the user really meant in the case of transcription errors
$ suggestions = iban_mistranscription_suggestions ( $ bad_iban );
if ( count ( $ suggestions ) == 1 ) {
print " You really meant " . $ suggestions [ 0 ] . " , right? n" ;
}
# Find the correct checksum for an IBAN
$ correct_checksum = iban_find_checksum ( $ iban );
# Set the correct checksum for an IBAN
$ fixed_iban = iban_set_checksum ( $ iban );
# Verify the pre-IBAN era, BBAN-level national checksum for those countries that
# have such a system and we have implemented.
# (Returns '' if unimplemented, true or false)
$ result = iban_verify_nationalchecksum ( $ iban );
if ( $ result == '' ) {
print " National checksum system does not exist or remains unimplemented for the country of IBAN ' $ iban '. n" ;
}
elseif ( $ result == true ) {
print " IBAN ' $ iban ' passes the national checksum algorithm for its country. n" ;
}
else {
print " IBAN ' $ iban ' FAILS the national checksum algorithm for its country. n" ;
}
# Set the pre-IBAN era, BBAN-level national checksum for those countries that
# have such a system, where that system results in a dedicated checksum
# substring, and that we have implemented.
# (Returns '' if unimplemented, or the corrected string)
# (NOTE: On success, the function also subsequently recalculates the IBAN-level checksum)
$ national_checksum_algorithm_valid_iban = iban_set_nationalchecksum ( $ iban );
# Determine, but do not set, the pre-IBAN era, BBAN-level national checksum
# for those countries that have such a system, where that system results in
# a dedicated checksum substring, and that we have implemented.
# (Returns '' if unimplemented, or the expected national checksum substring)
$ expected_national_checksum = iban_find_nationalchecksum ( $ iban ); # Convert an IBAN to machine format. To do this, we
# remove IBAN from the start, if present, and remove
# non basic roman letter / digit characters
$ machine_iban = iban_to_machine_format ( $ iban );
# Convert an IBAN to human format. To do this, we
# add a space every four characters.
$ human_iban = iban_to_human_format ( $ iban );
# Convert an IBAN to obfuscated format for relative
# identification. To do this, we replace all but the
# leading country code and final four characters with
# asterisks.
$ obfuscated_iban = iban_to_obfuscated_format ( $ iban ); # Get the name of an IBAN country
$ country_name = iban_country_get_country_name ( $ iban_country );
# Get the domestic example for an IBAN country
$ country_domestic_example = iban_country_get_domestic_example ( $ iban_country );
# Get the BBAN example for an IBAN country
$ country_bban_example = iban_country_get_bban_example ( $ iban_country );
# Get the BBAN format (in SWIFT format) for an IBAN country
$ country_bban_format_as_swift = iban_country_get_bban_format_swift ( $ iban_country );
# Get the BBAN format (as a regular expression) for an IBAN country
$ country_bban_format_as_regex = iban_country_get_bban_format_regex ( $ iban_country );
# Get the BBAN length for an IBAN country
$ country_bban_length = iban_country_get_bban_length ( $ iban_country );
# Get the IBAN example for an IBAN country
$ country_iban_example = iban_country_get_iban_example ( $ iban_country );
# Get the IBAN length for an IBAN country
$ country_iban_length = iban_country_get_iban_length ( $ iban_country );
# Get the IBAN format (in SWIFT format) for an IBAN country
$ country_iban_format_as_swift = iban_country_get_iban_format_swift ( $ iban_country );
# Get the IBAN format (as a regular expression) for an IBAN country
$ country_iban_format_as_regex = iban_country_get_iban_format_regex ( $ iban_country );
# Determine whether an IBAN country is a member of SEPA (Single Euro Payments Area)
if (! iban_country_is_sepa ( $ iban_country )) {
# ... do something xenophobic ...
}
# Get the bank ID start offset for an IBAN country
$ country_bankid_start_offset = iban_country_get_bankid_start_offset ( $ iban_country );
# Get the bank ID stop offset for an IBAN country
$ country_bankid_stop_offset = iban_country_get_bankid_stop_offset ( $ iban_country );
# Get the branch ID start offset for an IBAN country
$ country_branchid_start_offset = iban_country_get_branchid_start_offset ( $ iban_country );
# Get the branch ID stop offset for an IBAN country
$ country_branchid_stop_offset = iban_country_get_branchid_stop_offset ( $ iban_country );
# Get the registry edition for an IBAN country (note: IIBAN country 'AA' returns 'N/A')
$ country_registry_edition = iban_country_get_registry_edition ( $ iban_country );
# Determine whether an IBAN country is an official, SWIFT issued country record
if (! iban_country_get_country_swift_official ( $ iban_country )) {
# ... do something against decentralization ...
}
# Get the IANA code for an IBAN country
$ country_iana = iban_country_get_iana ( $ iban_country );
# Get the ISO3166-1 alpha-2 code for an IBAN country
$ country_iso3166 = iban_country_get_iso3166 ( $ iban_country );
# Get the parent registrar IBAN country of an IBAN country
# (Returns '' in the normal case that the country is independently registered)
$ registrar_country = iban_country_get_parent_registrar ( $ iban_country );
if ( $ registrar_country == '' ) {
print " The mighty nation of ' $ iban_country ' stands strong and proud... n" ;
print " ... with its own heirarchy of bureaucrats! n" ;
}
else {
print " It has been foretold that the downtrodden natives of ' $ iban_country ' will one day n" ;
print " rise up and throw off the shackles of the evil ' $ registrar_country ' oppressors! n" ;
}
# Get the official currency of an IBAN country as an ISO4217 alpha code
# (Returns '' in the Internet (IIBAN) case, ie. no official currency)
$ official_currency = iban_country_get_currency_iso4217 ( $ iban_country );
if ( $ official_currency == '' ) {
print " There is no official currency for the IBAN country ' $ iban_country '. n" ;
}
# Get the URL of an IBAN country's central bank
# (Note: Returns '' if there is no central bank. Also, note that
# sometimes multiple countries share one central bank)
$ central_bank_url = iban_country_get_central_bank_url ( $ iban_country );
# Get the name of an IBAN country's central bank
# (Note: Returns '' if there is no central bank. Also, note that
# sometimes multiple countries share one central bank)
$ central_bank_name = iban_country_get_central_bank_name ( $ iban_country );
# Get the membership type of the country
# There are four types of memberships:
# * EU-Member States (eu_member)
# * EFTA-Member States (efta_member)
# * Other Memberships, which have monetary agreements with the EU (other_member)
# * Non-Members, which don't belong to the EU or have agreements (non_member)
$ country_membership = iban_country_get_membership ( $ iban_country );
# Get if the country is a eu member state
# (Note: Returns true, if member state; false otherwise)
$ country_membership = iban_country_get_is_eu_member ( $ iban_country ); # Get an array of all the parts from an IBAN
$ iban_parts = iban_get_parts ( $ iban );
# Get the country part from an IBAN
$ iban_country = iban_get_country_part ( $ iban );
# Get the BBAN part from an IBAN
$ bban = iban_get_bban_part ( $ iban );
# Get the Bank ID (institution code) from an IBAN
$ bank = iban_get_bank_part ( $ iban );
# Get the Branch ID (sort code) from an IBAN
# (NOTE: only available for some countries)
$ sortcode = iban_get_branch_part ( $ iban );
# Get the (branch-local) account ID from an IBAN
# (NOTE: only available for some countries)
$ account = iban_get_account_part ( $ iban );
# Get the checksum part from an IBAN
$ checksum = iban_get_checksum_part ( $ iban );
# Get the national checksum part from an IBAN (if it exists)
$ checksum = iban_get_nationalchecksum_part ( $ iban );不鼓勵使用物件導向,因為目前存在過度使用該模型的趨勢。但是,如果您更喜歡 OO PHP,那麼請務必使用物件導向的包裝器,如下所述。
require_once ( ' oophp-iban.php ' );
# ... your code utilising object oriented php iban functions... # Example instantiation
$ iban = ' AZ12345678901234 '
$ myIban = new IBAN ( $ iban );
# Verify an IBAN number.
# Tolerates spaces, prefixes "IBAN ...", dashes, lowercase input, etc.
# Returns true or false.
if (! $ myIban -> Verify ()) {
# ...
}
# Verify an IBAN number in machine format only.
# Does not tolerate lowercase input, separators, whitespace or prefixes.
# Returns true or false.
if (! $ myIban -> VerifyMachineFormatOnly ()) {
# ...
}
# Check the checksum of an IBAN - code modified from Validate_Finance PEAR class
if (! $ myIban -> VerifyChecksum ()) {
# ...
}
# Suggest what the user really meant in the case of mistranscription errors
$ suggestions = $ badIban -> MistranscriptionSuggestions ();
if ( count ( $ suggestions )== 1 ) {
print " You really meant " . $ suggestions [ 0 ] . " , right? n" ;
}
# Find the correct checksum for an IBAN
$ correct_checksum = $ myIban -> FindChecksum ();
# Set the correct checksum for an IBAN
$ fixed_iban = $ myIban -> SetChecksum ()
# Verify the pre-IBAN era, BBAN-level national checksum for those countries that
# have such a system and we have implemented.
# (Returns '' if unimplemented, true or false)
$ result = $ myIban -> VerifyNationalChecksum ();
if ( $ result == '' ) {
print " National checksum system does not exist or remains unimplemented for this IBAN's country. n" ;
}
elseif ( $ result == true ) {
print " IBAN passes the national checksum algorithm for its country. n" ;
}
else {
print " IBAN FAILS the national checksum algorithm for its country. n" ;
}
# Set the pre-IBAN era, BBAN-level national checksum for those countries that
# have such a system, where that system results in a dedicated checksum
# substring, and that we have implemented.
# (Returns '' if unimplemented, or the corrected string)
# (NOTE: On success, the function also subsequently recalculates the IBAN-level checksum)
$ myIban -> SetNationalChecksum ();
# Determine, but do not set, the pre-IBAN era, BBAN-level national checksum
# for those countries that have such a system, where that system results in
# a dedicated checksum substring, and that we have implemented.
# (Returns '' if unimplemented, or the expected national checksum substring)
$ national_checksum = $ myIban -> FindNationalChecksum (); # Convert an IBAN to machine format. To do this, we
# remove IBAN from the start, if present, and remove
# non basic roman letter / digit characters
$ machine_iban = $ myIban -> MachineFormat ();
# Convert an IBAN to human format. To do this, we
# add a space every four characters.
$ human_iban = $ myIban -> HumanFormat ();
# Convert an IBAN to obfuscated format for relative
# identification. To do this, we replace all but the
# leading country code and final four characters with
# asterisks.
$ obfsucated_iban = $ myIban -> ObfuscatedFormat (); # To list countries, use the IBAN Class...
$ myIban -> Countries ();
# ... everything else is in the IBANCountry class.
# Example instantiation
$ countrycode = ' DE ' ;
$ myCountry = new IBANCountry ( $ countrycode );
# Get the country code of an IBAN country
$ country_code = $ myCountry -> Code ();
# Get the name of an IBAN country
$ country_name = $ myCountry -> Name ();
# Get the domestic example for an IBAN country
$ country_domestic_example = $ myCountry -> DomesticExample ();
# Get the BBAN example for an IBAN country
$ country_bban_example = $ myCountry -> BBANExample ();
# Get the BBAN format (in SWIFT format) for an IBAN country
$ country_bban_format_as_swift = $ myCountry -> BBANFormatSWIFT ();
# Get the BBAN format (as a regular expression) for an IBAN country
$ country_bban_format_as_regex = $ myCountry -> BBANFormatRegex ();
# Get the BBAN length for an IBAN country
$ country_bban_length = $ myCountry -> BBANLength ();
# Get the IBAN example for an IBAN country
$ country_iban_example = $ myCountry -> IBANExample ();
# Get the IBAN length for an IBAN country
$ country_iban_length = $ myCountry -> IBANLength ();
# Get the IBAN format (in SWIFT format) for an IBAN country
$ country_iban_format_as_swift = $ myCountry -> IBANFormatSWIFT ();
# Get the IBAN format (as a regular expression) for an IBAN country
$ country_iban_format_as_regex = $ myCountry -> IBANFormatRegex ();
# Determine whether an IBAN country is a member of SEPA (Single Euro Payments Area)
if (! $ myCountry -> IsSEPA ()) {
# ... do something xenophobic ...
}
# Get the bank ID start offset for an IBAN country
$ country_bankid_start_offset = $ myCountry -> BankIDStartOffset ();
# Get the bank ID stop offset for an IBAN country
$ country_bankid_stop_offset = $ myCountry -> BankIDStopOffset ();
# Get the branch ID start offset for an IBAN country
$ country_branchid_start_offset = $ myCountry -> BranchIDStartOffset ();
# Get the branch ID stop offset for an IBAN country
$ country_branchid_stop_offset = $ myCountry -> BranchIDStopOffset ();
# Get the national checksum start offset for an IBAN country
$ country_nationalchecksum_start_offset = $ myCountry -> NationalChecksumStartOffset ();
# Get the national checksum stop offset for an IBAN country
$ country_nationalchecksum_stop_offset = $ myCountry -> NationalChecksumStopOffset ();
# Get the registry edition for an IBAN country (note: IIBAN country 'AA' returns 'N/A')
$ country_registry_edition = $ myCountry -> RegistryEdition ();
# Determine whether an IBAN country is an official, SWIFT issued country record
if (! $ myCountry -> SWIFTOfficial ()) {
# ... do something against decentralization ...
}
# Get the IANA code for an IBAN country
$ country_iana = $ myCountry -> IANA ();
# Get the ISO3166-1 alpha-2 code for an IBAN country
$ country_iso3166 = $ myCountry -> ISO3166 ();
# Get the parent registrar IBAN country of an IBAN country
# (Returns '' in the normal case that the country is independently registered)
$ registrar_country = $ myCountry -> ParentRegistrar ();
if ( $ registrar_country == '' ) {
print " The mighty nation of ' $ iban_country ' stands strong and proud... n" ;
print " ... with its own heirarchy of bureaucrats! n" ;
}
else {
print " It has been foretold that the downtrodden natives of ' $ iban_country ' will one day n" ;
print " rise up and throw off the shackles of the evil ' $ registrar_country ' oppressors! n" ;
}
# Get the official currency of an IBAN country as an ISO4217 alpha code
# (Returns '' in the Internet (IIBAN) case, ie. no official currency)
$ official_currency = $ myCountry -> CurrencyISO4217 ();
if ( $ official_currency == '' ) {
print " There is no official currency for the IBAN country ' $ iban_country '. n" ;
}
# Get the URL of an IBAN country's central bank
# (Note: Returns '' if there is no central bank. Also, note that
# sometimes multiple countries share one central bank)
$ central_bank_url = $ myCountry -> CentralBankURL ();
# Get the name of an IBAN country's central bank
# (Note: Returns '' if there is no central bank. Also, note that
# sometimes multiple countries share one central bank)
$ central_bank_name = $ myCountry -> CentralBankName (); # Get an array of all the parts from an IBAN
$ iban_parts = $ myIban -> Parts ();
# Get the country part from an IBAN
$ iban_country = $ myIban -> Country ();
# Get the checksum part from an IBAN
$ checksum = $ myIban -> Checksum ();
# Get the BBAN part from an IBAN
$ bban = $ myIban -> BBAN ();
# Get the Bank ID (institution code) from an IBAN
$ bank = $ myIban -> Bank ();
# Get the Branch ID (sort code) from an IBAN
# (NOTE: only available for some countries)
$ sortcode = $ myIban -> Branch ();
# Get the (branch-local) account ID from an IBAN
# (NOTE: only available for some countries)
$ account = $ myIban -> Account ();
# Get the national checksum part from an IBAN
# (NOTE: only available for some countries)
$ checksum = $ myIban -> NationalChecksum ();親自看看我們的方法和功能如何與所有這些庫相比...
| 語言 | 圖書館 |
|---|---|
| C# | iban-api-網 |
| 爪哇 | iban-api-java |
| 爪哇 | 伊班4j |
| 爪哇 | 爪哇伊班 |
| JavaScript | iban.js |
| JavaScript | 恩伊班 |
| 目標C | IBAN 助手 |
| 目標C | iban驗證 |
| 珀爾 | 各種 CPAN 庫 |
| Python | django-localflavor |
| Python | iban-生成器 |
| 紅寶石 | 銀行 |
| 紅寶石 | iban-工具 |
| 紅寶石 | 伊班迪特 |
| 紅寶石 | 伊巴尼札特 |
| 紅寶石 | 異伊班 |