php计算舍入差及Ubuntu升级php版本

1解决计算的舍入差

bcmath系列函数,两个任意精度数字之间的运算。

大多数编程语言对于浮点型数据格式遵循 IEEE 754 标准,这就会导致在使用浮点数运算的过程中会有精度丢失的问题。PHP提供了 BCMath 库来支持更加精确的计算

2ubuntu php7.0升级为7.2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1删除php的相关包及配置
sudo apt-get autoremove php7*
2删除关联
sudo find /etc -name "*php*" | sudo xargs rm -rf
3清除dept列表
sudo apt purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
4检查是否卸载干净(无返回就是卸载完成)
dpkg -l | grep php7.0

安装php7.2

php -v //查看版本
sudo add-apt-repository ppa:ondrej/php //添加源
sudo apt-get update //更新源
sudo apt-get install php7.2 //安装
php -v //查看版本
sudo apt-get install php7.2-mysql //安装2个扩展包
sudo apt-get install php7.2-fpm
sudo apt-get install php7.2-curl
//选择安装扩展包
php7.2-dom php7.2-gd php7.2-mbstring php7.2-memcached php7.2-zip

sudo service php7.2-fpm restart //启动fpm服务

更新gninx配置文件
location ~ \.php$ {
include snippets/fastcgi-php.conf; -》更换为了include fastcgi.conf
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; -》其中php7.0-fpm.sock更换为了php7.2-fpm.sock

3二维数组根据其中一个key排序

array_column()与array_multisort()

参考链接:https://www.cnblogs.com/wenzheshen/p/9455554.html