php 7 新增内容介绍
2015年的夏天,虽然来得不算火热,但是在互联网技术的夏天,比任何一年都更为火热。
刚刚才结束了 5 月底的网易、支付宝、携程以及多家云存储厂商的接连故障的坏消息,6月上旬则迎来了编程语言界两大好消息,第一件是 Swift 2.0 发布以及开源,另一件是PHP 7 alpha版正式发布。这两件大事,都是可以载入相应的编程语言的史册级的事件。
Swift 2.0 的事,咱先不说了,本文的重点是带着大家见识一下鸟哥等众位大神打磨了2年的PHP 7,看看是否真的如之前所说的霸气。以及测试了一下现有软件和扩展的兼容性。
PHP7的安装,真是非常地向下兼容,下载,解压,把之前的配置命令用上,一路回车下去,毫无违和感。为了不影响现有的环境的运行,所有专门开辟了目录 。
配置参数如下:
--prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts
ln -s /usr/local/php7/bin/php /usr/bin/php7
ln -s /usr/local/php7/bin/php-config /usr/bin/php7-config ln -s /usr/local/php7/bin/phpize /usr/bin/php7ize
ln -s /usr/local/php7/sbin/php-fpm /usr/sbin/php7-fpm[root@localhost test]# php7 -v
PHP 7.0.0alpha1 (cli) (built: Jun 13 2015 11:33:39) Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies<?php $a = array(); for($i=0;$i<600000;$i++){ $a[$i] = $i;
} foreach($a as $i)
{
array_key_exists($i, $a);
}[root@localhost test]# time php search_by_key.php
real 0m0.389s
user 0m0.337s
sys 0m0.051s
[root@localhost test]# time php search_by_key.php
real 0m0.378s
user 0m0.308s
sys 0m0.062s
[root@localhost test]# time php search_by_key.php
real 0m0.378s
user 0m0.317s
sys 0m0.061s[root@localhost test]# time php7 search_by_key.php
real 0m0.139s
user 0m0.055s
sys 0m0.048s
[root@localhost test]# time php7 search_by_key.php
real 0m0.089s
user 0m0.058s
sys 0m0.030s
[root@localhost test]# time php7 search_by_key.php
real 0m0.097s
user 0m0.065s
sys 0m0.022s<?php
$a = array();
for($i=0;$i<60000;$i++){
$a[$i] = $i;
}
foreach($a as $i) {
array_search($i, $a);
}
[root@localhost test]# time php search_by_val.php
real 0m24.296s
user 0m24.184s
sys 0m0.025s
[root@localhost test]# time php search_by_val.php
real 0m25.523s
user 0m25.317s
sys 0m0.026s
[root@localhost test]# time php search_by_val.php
real 0m26.026s
user 0m25.478s
sys 0m0.092s[root@localhost test]# time php7 search_by_val.php
real 0m3.439s
user 0m3.410ssys 0m0.008s
[root@localhost test]# time php7 search_by_val.php
real 0m3.426suser 0m3.409s
sys 0m0.007s
[root@localhost test]# time php7 search_by_val.php
real 0m3.616suser 0m3.400s
sys 0m0.018s[root@localhost test]# time php7 prime_v3.php 2000000 prime number count under 2000000 is :148933 real 0m1.211s
user 0m1.191s
sys 0m0.015s
[root@localhost test]# time php7 prime_v3.php 2000000 prime number count under 2000000 is :148933 real 0m1.221s
user 0m1.207s
sys 0m0.010s
[root@localhost test]# time php7 prime_v3.php 2000000 prime number count under 2000000 is :148933 real 0m1.220s
user 0m1.201s
sys 0m0.015s[root@localhost test]# time php prime_v3.php 2000000 prime number count under 2000000 is :148933 real 0m4.425s
user 0m4.380s
sys 0m0.023s
[root@localhost test]# time php prime_v3.php 2000000 prime number count under 2000000 is :148933 real 0m4.457s
user 0m4.414s
sys 0m0.032s
[root@localhost test]# time php prime_v3.php 2000000 prime number count under 2000000 is :148933 real 0m4.464s
user 0m4.399s
sys 0m0.046s





参考来源:
php 7 新增内容介绍
http://www.lai18.com/content/434544.html
以上就介绍了php 7 新增内容介绍,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号