Home > Backend Development > PHP Tutorial > How to install BCMath extension in PHP?

How to install BCMath extension in PHP?

青灯夜游
Release: 2023-04-05 12:08:02
forward
9880 people have browsed it

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
Copy after login

3. Pre-compile

./configure --with-php-config=/usr/local/php-7.2.12/bin/php-config
Copy after login

4. Compile && install

make && make install
Copy after login

5. Add the extension to php.ini (my php.ini is in /usr/ local/php/lib directory)

extension=bcmath.so
Copy after login

How to install BCMath extension in PHP?

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!

Related labels:
php
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template