sicaa / number-to-fr-words
简单有效的库,用于将数字转换为法语单词
1.0.1
2024-09-14 12:21 UTC
Requires
- php: >=7.4 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^9
This package is not auto-updated.
Last update: 2024-09-20 03:13:06 UTC
README
英语
我编写了这个小巧的库,以便轻松地将数字转换为法语单词。这个项目是在我需要为客户自动填写银行支票时出现的。当时,唯一的解决方案是使用一个旧的重型Pear包(https://pear.php.net/package/Numbers_Words)。因此,以下文档是用法语编写的。
法语
简单的PHP库,用于将数字转换为(法语)单词。这个项目是在我需要为客户自动在支票上书写时产生的。当时,唯一的解决方案是使用一个旧的Pear库(https://pear.php.net/package/Numbers_Words)。
使用方法
composer require sicaa/number-to-fr-words
<?php use Sicaa\NumberToFrWords\NumberToFrWords; var_dump(NumberToFrWords::output(1337)); // string(29) "mille trois cent trente-sept"
限制
支持的最大数字取决于使用该工具的平台。超过PHP_INT_MAX
的值,PHP将整数解释为十进制数(参见https://php.ac.cn/manual/fr/language.types.integer.php)。由于该类不支持非整数,在64位平台上,支持的最大数字是9223372036854775807
。
<?php var_dump(NumberToFrWords::output(9223372036854775807)); // string(192) "neuf quintillions deux cent vingt-trois quadrillions trois cent soixante-douze trillions trente-six milliards huit cent cinquante-quatre millions sept cent soixante-quinze mille huit cent sept" var_dump(NumberToFrWords::output(9223372036854775808)); // Fatal error: Uncaught exception 'Exception' with message 'NumberToFrWords::output: $number must be an integer'