PHP7 RC7 Release Contrast PHP5.6 Quick sort 20000 data performance experience and new grammar taste

Source: Internet
Author: User
Tags add anonymous end net sort version unsupported zend

Recently Zend's PHP7 has been in the final bug fix phase, has been updated RC7, for Zend's official claim PHP7 performance is approximately twice times higher than the PHP5 series version, adding some new syntax, rejecting some of the PHP5 factors affecting performance, The following features were mainly added.

  • Improved performance:php 7 is up to twice as fast as PHP 5.6 performance is twice times higher than 5.6 consistent 64-bit support 64-bit consistent support many fatal RS are now exceptions adds many fatal error exceptions removal the old and unsupported Sapis and extensions remove the older unsupported Sapis and some extend the null Coalesc ing operator (??) Null merge operator Combined comparison operator (<=>) The return value type shown in conjunction with comparison operator returns type Declarations and C language scalar Type Declarations scalar type definition anonymous Classes anonymous class! In a curious mindset. I also installed PHP5.5 and PHP7 RC7 release, experience, and then experience the PHP7 performance and new syntax, as to how Install configuration PHP7 I don't think I have to say that.
    HTTP://PHP.NET/PHP7 RC7 Release official address PHP7 Wiki

    1, PHP7 and PHP5.5 performance comparison

    PHP7 performance relative to the PHP5.6 increased how much, the following with a simple and silly code to test the know, here I use the 5.5 version of PHP contrast it, the computer only 5.5 lazy to install PHP5.6.
    Figure PHP7 and php5.5 as follows:

    1.1 I'm here to test PHP with a little piece of code:
        $high) return
     $begin = $low;
     $end = $high;
     $key = $arr [$begin];
     while ($begin < $end)
    	($begin < $end && $arr [$end]>= $key)-
    	$arr [$begin]= $arr [$end];
    	while ($begin < $end && $arr [$begin]<= $key)
    	  + + $begin;
    	$arr [$end]= $arr [$begin];
      $arr [$begin]= $key;
      QuickSort ($arr, $low, $begin-1);
      QuickSort ($arr, $begin +1, $high);
    $time _start = Microtime_float ();
    $arr =array ();
    for ($i =0; $i
    1.2 Test ResultsAfter running 20000 random data fast sorting algorithm under PHP7 and PHP5.5 respectively, the result PHP7 is 12 times times that of PHP5.5!!!! Looks like PHP7 's starting to get hung up!

    The following is the speed at which PHP7 RC7 and PHP5 run these fast-sorted 20000 data algorithms.

    2, PHP7 new grammar experience

    2.1, scalar type and strong type PHP7新增四个标量类型 int,float,string bool, 首先要使用强类型 必须在文件中加入指令

  • declare(strict_types=1)该指令必须是第一个指令而且只有一种用法 The concept of the strict type strong type is that we want to discard the notion of type before PHP5.6, because we know that PHP itself is a type language, and because of this, the behavior of the PHP language itself is very low due to the type-conversion already type checking PHP7 The move also proves this, such as the following code

    If the above code to return 1 to normal operation, otherwise the operation will be an error, this is the strong type of PHP7 constraints, this mode completely abandon if the type.

    2.2 Strong type parameters
    The result of the var_dump is int (3)
    2.3 Return type conflictReturns the difference between a value type and a strongly typed constraint will run out of exception
        GetMessage ();

    OK about scalar type is not a one written
    For more information please refer to:

    2.4, about PHP Anonymous Class simple anonymous class inheritance
        M2 ()->m1 ();
    ? >

    simple Anonymous class instantiation
        i = $i;
    ? >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.