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->NationalChecksum()
、 $myCountry->NationalChecksumStartOffset()
和$mycountry->NationalChecksumStopOffset()
进行查询。测试和文档已更新。如果您了解有关国家校验和算法的任何信息,请在第 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 页面。强调转录错误错误的支持。
最后,谷歌已经关闭了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 Internet草案,该版本添加了Internet国际银行帐号(IIBAN)支持
版本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)
在本月早些时候...较小的维护版本,不是关键。
*我们现在有一个http://groups.google.com/group/php-iban-users邮件列表。请随时发布您的反馈,查询或建议 - 我们很想知道您的使用方式。迄今为止,该项目已达到400多个下载量,并且仍在强大,每天有一个以上的新用户 - 对于专业图书馆来说,这是一个很好的展示!
*版本12已发布。注册表文件得到了改进,部分是由于用户报告的结果,部分是由于在针对版本11执行自动测试时发现的问题。
校正后行两列未在标题中表示( bban_length
和iban_length
)。现在已经添加了它们。
修复了法国领土的注册表条目(PF,TF,YT,NC,PM,WF)法国领土未明确包含在Swift Spectfile中。根据对该条目的非结构化评论,他们从法国重复了他们。然后,通过简单地修改国家前缀而无需再生校验和校验和来进行示例ibans出于说明目的。这些领土的IBAN示例现在应该是正确的。
直布罗陀和匈牙利(GI,HU)修复了一个错误,在该错误中,这两个领土在最初的文档转换后都贴在其正则表达式中,这导致了这些国家的所有IBAS验证失败。
毛里求斯(MU)纠正了伊班(Iban)的期望为31至30。
瑞典(SE)的例子伊班(Iban)在开发的早期就已经从伊班规格(Iban Specification)手动修改了,但没有通过校验和检查。 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。但是,如果您更喜欢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-net |
爪哇 | Iban-Api-Java |
爪哇 | iban4j |
爪哇 | Java-iban |
JavaScript | iban.js |
JavaScript | ng-ban |
目标C | 伊班助人 |
目标C | ibanvalidation |
珀尔 | 各种CPAN库 |
Python | django-localflavor |
Python | 伊班发电机 |
红宝石 | 银行 |
红宝石 | iban-tools |
红宝石 | ibandit |
红宝石 | ibanizator |
红宝石 | ISO-IBAN |