Home >Backend Development >PHP Tutorial >How to install BCMath extension in PHP?
The content of this article is to introduce how to install the BCMath extension in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
We all know that most programming languages follow the IEEE 754 standard for floating-point data formats, and PHP is no exception. This will lead to the problem of precision loss during the use of floating-point operations.
PHP provides the BCMath library to support more precise calculations. However, my PHP did not install the BCMath library when compiling. If it needs to be installed, just specify --enable-bcmath
when compiling and installing.
If it is missed during compilation and installation, we can also install the BCMath library separately. The steps for separate installation are provided below:
1. Enter ext/bcmatch in the PHP source code package directory. directory (mine is /usr/src/php-7.2.12/ext/bcmath).
2. Execute the phpize command. The phpize command is in the bin directory of the PHP installation directory (my directory is /usr/local/php-7.2.12/bin/phpize).
# 如果已经把PHP的bin目录添加到系统环境变量,则直接在bcmath目录下执行phpize即可 phpize #否则,要在bcmath目录下指定phpize命令的路径 /usr/local/php-7.2.12/bin/phpize
3. Pre-compile
./configure --with-php-config=/usr/local/php-7.2.12/bin/php-config
4. Compile && install
make && make install
5. Add the extension to php.ini (my php.ini is in /usr/ local/php/lib directory)
extension=bcmath.so
6. Restart the PHP service.
The above is the detailed content of How to install BCMath extension in PHP?. For more information, please follow other related articles on the PHP Chinese website!