Web Development

Install BCmath Extension in PHP

PHP Code

PHP offers various extensions 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.

 

[gads]

BC Stands for Binary Calculator

Install BCMath Extension in PHP – Windows

The installation of PHP extension in PHP is very simple. Open your active php.ini and look for the line [code]extension=php_bcmath.dll[/code]. If that line is commented with [code];[/code] at the start then you just need to remove that [code];[/code] 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

[cc lang=”php”]
sudo apt install php5.6-bcmath
[/cc]

[gads]

PHP 7.0

[cc lang=”php”]
sudo apt install php7.0-bcmath
[/cc]

Other PHP Version

[cc lang=”php”]
sudo apt install php-bcmath
[/cc]

If you are not sure which version of PHP you are using then you can type [code]php -v[/code] 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 the 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

[cc lang=”php”]
sudo yum install php56u-bcmath
[/cc]

PHP 7

[cc lang=”php”]
sudo yum install php7.0-bcmath
[/cc]

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

After the extension is installed you need to restart apache using [code]sudo service httpd restart[/code] and you are done with the 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.

Shares:

Leave a Reply

Your email address will not be published. Required fields are marked *