phpseclib / bcmath_compat
bcmath扩展的PHP 5.x-8.x polyfill
2.0.3
2024-06-06 14:17 UTC
Requires
- phpseclib/phpseclib: ^3.0
Requires (Dev)
- phpunit/phpunit: ^4.8.35|^5.7|^6.0|^9.4
- squizlabs/php_codesniffer: ^3.0
Suggests
- ext-gmp: Will enable faster math operations
Provides
- ext-bcmath: 8.1.0
README
bcmath扩展的PHP 5.x-8.x polyfill
安装
使用Composer
$ composer require phpseclib/bcmath_compat
限制
-
extension_loaded('bcmath')bcmath_compat无法使此返回true。建议的补救措施是不要这样做。
-
ini_set('bcmath.scale', ...)您无法为未安装的扩展设置配置选项。如果您在一个没有安装bcmath的系统上使用
ini_set('bcmath.scale', 5),那么ini_get('bcmath.scale')将返回false。这和您执行ini_set('zzz', 5)然后执行ini_get('zzz')时的行为类似。您将得到false。对执行
ini_set('bcmath.scale', ...)的建议补救措施是执行bcscale(...)。对执行ini_get的建议补救措施是(如果您使用PHP >= 7.3.0),执行bcscale();如果您使用的是PHP < 7.3.0,则执行max(0, strlen(bcadd('0', '0')) - 2)。请注意,
ini_get始终返回字符串,而建议的补救措施返回整数。