PHP 7.0 Alpha 1 新特性概览
2026年6月11日,PHP官方宣布正式发布PHP 7的第一个Alpha版本。
PHP 7的主要特性如下:
PHP 7.0.0 Alpha 1采用了全新的Zend Engine引擎,带来了多项新特性,以下列举部分核心更新:
(1)性能显著优化:PHP 7的运行速度比PHP 5.6快了两倍。Improved performance: PHP 7 is up to twice as fast as PHP 5.6
(2)提供完整的64位支持。Consistent 64-bit support
(3)将以往许多致命错误转换为异常抛出。Many fatal errors are now Exceptions
(4)移除了旧版且不再支持的SAPI(服务器端应用编程接口)及扩展。Removal of old and unsupported SAPIs and extensions
(5)新增空接合操作符。The null coalescing operator (??)
(6)新增结合比较运算符。Combined comparison Operator (<=>)
(7)新增函数返回类型声明。Return Type Declarations
(8)新增标量类型声明。Scalar Type Declarations
(9)新增匿名类支持。Anonymous Classes
php7安装笔记整理
# 安装mcrypt扩展
yum install -y php-mcrypt libmcrypt libmcrypt-devel
# 升级bison工具
cd /var/soft/
wget http://ftp.gnu.org/gnu/bison/bison-2.6.4.tar.gz
tar -xvzf bison-2.6.4.tar.gz
cd bison-2.6.4
./configure
make && make install
# 升级re2c,以解决若需重新生成PHP解析器时提示需要re2c 0.13.4或更高版本的错误
parsers.错误
cd /var/soft/
wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
tar zxf re2c-0.13.5.tar.gz && cd re2c-0.13.5
./configure
make && make install
编译PHP 7源码
# 创建目录
mkdir -p /var/soft/php7
cd /var/soft/php7
# 下载源代码
git clone http://git.php.net/repository/php-src.git
cd php-src
./buildconf
# 配置参数
./configure --prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--with-mcrypt=/usr/include \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache
#################################################################################
# 编译安装php时出现 /encodings.c:101: undefined reference to `libiconv_close' 错误的解决方法
# 在装php时出现以下的错误:
# /root/Downloads/php-5.6.5/ext/xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv_open'
# /root/Downloads/php-5.6.5/ext/xmlrpc/libxmlrpc/encodings.c:81: undefined reference to `libiconv'
# /root/Downloads/php-5.6.5/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close'
# /root/Downloads/php-5.6.5/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close'
# collect2: error: ld returned 1 exit status
# make: *** [sapi/cli/php] Error 1
# 根据php官网描述这是一个bug(https://bugs.php.net/bug.php?id=52611)。在configure以后要手动修改下Makefile文件,找到EXTRA_LIBS 在最后添加 -liconv 即可顺利通过
# (大约在Makefile文件的104)
# EXTRA_LIBS = -lcrypt -lz -lresolv -lcrypt -lrt -lmysqlclient -lmcrypt -lltdl -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lxml2 -lz -lm -ldl -lssl -lcrypto -lcurl -lxml2 -lz -lm -ldl -lfreetype -lmysqlclient -lz -lm -lssl -lcrypto -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lssl -lcrypto -lcrypt -liconv
#################################################################################
# 编译安装
make && sudo make install
# 配置编译参数
cp php.ini-production /usr/local/php7/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
chmod +x /etc/init.d/php7-fpm
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
# 配置opcache缓存
vim /usr/local/php7/etc/php.ini
# 加入
zend_extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20141001/opcache.so
# 启动
/etc/init.d/php7-fpm start
# 验证PHP版本
/usr/local/php7/bin/php -v
输出结果:
PHP 7.0.0-dev (cli) (built: Mar 3 2026 10:02:26)
Copyright (c) 1997-2026 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2026 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2026, by Zend Technologies
以上为PHP 7.0安装笔记的整理内容,希望能对大家有所帮助。