Install BCmath Extension in PHP

PHP offers a various extension to deal with different cases. BCMath is one of PHP extension which helps us while working with float values in PHP. In BCMath, BC Stands for Binary Calculator. In this article, we will see how to Install BCMath Extension in PHP on various platforms.

Install BCMath Extension in PHP

BC Stands for Binary Calculator

Install BCMath Extension in PHP – Windows

Installation of PHP extension in PHP is very simple. Open your active php.ini and look for the line extension=php_bcmath.dll. If that line is commented with ; at the start then you just need to remove that ; and restart apache will load this BCMath extension with PHP.

Install BCMath Extension in PHP – Ubuntu

To install PHP extension in Ubuntu you will need either root or sudo user access. We will see how BCMath extension can be installed on various versions of PHP.

PHP 5.6

1
sudo apt install php5.6-bcmath

PHP 7.0

1
sudo apt install php7.0-bcmath

Other PHP Version

1
sudo apt install php-bcmath

If you are not sure which version of PHP you are using then you can type php -v in your terminal and you will get a version of PHP installed.

If all the above method did not work for you then you can search for all available module which is related to PHP. Type apt-cache search php in your terminal and it will list all PHP modules and extension which are compatible with your PHP version.

Once an extension is installed using any of the above methods then you need to restart apache server in order to load BCMath extension in PHP.

Install BCMath Extension in PHP – CentOS

Same as Ubuntu you will need root or sudo user access to install an extension in PHP.

PHP 5.6

1
sudo yum install php56u-bcmath

PHP 7

1
sudo yum install php7.0-bcmath

If above did not work for you then you can search for an available package for your PHP version using sudo yum search bcmath and it will show available bcmath package for your PHP installation.

After the extension is installed you need to restart apache using sudo service httpd restart and you are done with installation of PHP BCMath extension.

In the next article, we will see what is the use of this PHP BCMath Extension while working with float values in PHP.

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by: