Skip to content

Commit c394fcd

Browse files
committed
add notes about limitations
1 parent 3846236 commit c394fcd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ With [Composer](https://getcomposer.org/):
1313
$ composer require phpseclib/bcmath_compat
1414
```
1515

16+
## Limitations
17+
18+
- `extension_loaded('bcmath')`
19+
bcmath_compat cannot make this return true. The recommended remediation is to not do this.
20+
21+
- `ini_set('bcmath.scale', ...)`
22+
You cannot set configuration options for extensions that are not installed. If you do `ini_set('bcmath.scale', 5)` on a system without bcmath installed then `ini_get('bcmath.scale')` will return `false`. It's similar to what happens when you do `ini_set('zzz', 5)` and then `ini_get('zzz')`. You'll get `false` back.
23+
24+
The recommended remediation to doing `ini_set('bcmath.scale', ...)` is to do `bcscale(...)`. The recommended remediation for doing `ini_get` is (if you're using PHP >= 7.3.0) to do `bcscale()` or (if you're using PHP < 7.3.0) to do `max(0, strlen(bcadd('0', '0')) - 2)`.
25+
26+
Note that `ini_get` always returns a string whereas the recommended remediations return integers.
27+
1628
[ico-version]: https://img.shields.io/packagist/v/phpseclib/bcmath_compat.svg?style=flat-square
1729
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
1830
[ico-travis]: https://img.shields.io/travis/phpseclib/bcmath_compat/master.svg?style=flat-square

0 commit comments

Comments
 (0)