10

I need to enable BC Math, but I don't want to do it using --enable-bcmath, primarily because I don't understand that route.

Is there a way to do this using php.ini only?

  • 1
    To the best of my knowledge you must compile php with the --enable-bcmath option. Without it, the required code won't exist in the binary. Therefore, there is nothing that you can set in php.ini. – mlewis54 Apr 25 '13 at 15:00
  • I can't accept your answer, as it's only a comment. If you want to put it as an answer I'll accept it. –  Apr 28 '13 at 14:46

2 Answers2

13

To the best of my knowledge you must compile php with the --enable-bcmath option. Without it, the required code won't exist in the binary. Therefore, there is nothing that you can set in php.ini

mlewis54
  • 2,372
  • 6
  • 36
  • 58
  • 5
    or `apt-get install php5-bcmath` – nkamm May 02 '13 at 14:40
  • 1
    I'm getting `Unable to locate package php5-bcmath`. Does it have a different name now? – tim peterson Feb 05 '14 at 18:51
  • @nkamm In Ubuntu (and it's save to assume in Debian as well), `bcmath` is included as part of the `php5` source package and all `php5` binary packages in Ubuntu and Debian (since php 5.3.10 at least) have `bcmath` included by default, so you do not need to install any additional packages to get it. [I can show evidence (for Ubuntu at least) that supports this statement.](http://askubuntu.com/a/416875/10616) – Thomas Ward Feb 05 '14 at 19:17
  • 2
    Just go for "php-bcmath", it'll install the most recent package (today it'd be php7-bcmath) – manniL Jan 28 '17 at 12:21
  • 1
    @manniL is right that `php-bcmath` installs latest - but be aware - you only want that if you also want to have latest php - if your project runs e.g. on php 5.4 , install php5 packages ;) Sidenote: on Ubuntu 18.04 I had to install this package manually (for php 7.2.1) – jave.web Feb 07 '19 at 10:48
  • for me `sudo apt install php7.X-bcmath` resolved a problem – Lukasz Koziara Jul 06 '22 at 19:22
8

Before recompiling, check the php.ini file and search for "bcmath". You may find bcmath.scale=0. If so, change the 0 to a 2.

David Levine
  • 105
  • 1
  • 1