PHP7.2已经发布

PHP7.2.0的稳定版本已于2017-11-30发布。官方下载地址:http://php.net/downloads.php#v7.2.0

个人镜像
文件名下载链接文件大小sha256
php-7.2.0.tar.gz下载17,849Kb801876abd52e0dc58a44701344252035fd50702d8f510cda7fdb317ab79897bc
php-7.2.0-nts-Win32-VC15-x86.zip下载22.64MBf5c1317e557ec814377a18af3ad325a59da8a9d127660ab1a03562b14824f686
php-7.2.0-Win32-VC15-x86.zip下载22.7MB28bd43ba9148549f8b70b28ae33415b3103e3b3cbaabcd4619fdac47a1739f7f
php-7.2.0-nts-Win32-VC15-x64.zip下载24.28MB85a325601d0442dcefbd02fd859f3c6cc1580349857c2d21c8be58cd1e4d8f23
php-7.2.0-Win32-VC15-x64.zip下载24.41MB275c58e86e0490146684e4f731917484306a3f269dc6f6f55f31aabb808743d0

从低版本升级

windows系统

Win系统升级十分简单,下载官方已经编译好的二进制包,解压,更改环境变量之类的配置就可以用了。

linux系统

用apt、yum等包管理器安装的php无需多言。

编译安装的PHP,这个新版本的编译方式和上几个版本是一样的。如果你保留了上次你已经编译的php源代码,你可以把原来文件夹下的config.nice复制到新版本的源码包里,然后执行这个脚本。这个脚本可以执行你上次编译老版本时configure的命令,免去手动打选项的时间。configure后可直接make,make test,还有make install。注意,这次升级,必须重新编译php.ini里已经加载的扩展,否则PHP会出错。以前安装的扩展,新版本会忽视。

不向后兼容的修改

下面列出了PHP7.1升级到PHP7.2需要注意的事项。

尝试计数不可数的数据类型时会报错

当尝试向count函数(包括count函数的别名函数sizeof)传入不可数类型时,会抛出E_WARNING级别的错误。

<?php

var_dump(
    count(1), // 整型不可数
    count('abc'), // 字串符不可数
    count(new stdclass), // 没有实现Countable接口的对象是不可计数的
    count([1,2]) // 数组是可以计数的
);

以上例子会输出:

Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d

Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d

Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
int(1)
int(1)
int(1)
int(2)

简而言之,从PHP7.2开始,向count函数传入非数组或者没有实现Countable接口的对象时,PHP会报Warning级别的错误。

弃用的功能

each()函数已被弃用

《PHP7.2已经发布》上有3条评论

  1. I needed to thank you for this great read!! I certainly
    enjoyed every bit of it. I have you book-marked to look at new things you post…

  2. My brother recommended I would possibly like this web site.
    He used to be totally right. This post truly made my day.
    You cann't believe simply how a lot time I had spent
    for this info! Thank you!

回复 g 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据