PHP 7.0.0 - What Should You Know? - WIT Solution

Wednesday, 15 June 2016

PHP 7.0.0 - What Should You Know?

PHP 7.0.0 in general

The PHP development team announces the release of PHP 7.0.0. It marks the start of the new major PHP 7 series. All PHP 7.0 users are encouraged to upgrade to this version.PHP 7.0.0 is presented with a new version of the Zend Engine, numerous improvements and new features such as:

  • Significantly reduced memory usage
  • Improved performance: PHP 7 is up to twice as fast as PHP 5.6
  • Abstract Syntax Tree
  • Improved Exception hierarchy
  • Consistent 64-bit support
  • Many fatal errors converted to Exceptions
  • Removed old and unsupported SAPIs and extensions
  • Secure random number generator
  • The null coalescing operator (??)
  • Anonymous Classes
  • Return and Scalar Type Declarations
  • Zero cost asserts
The migration guide is available in the PHP Manual. If you want to go deeper into details, consult the manual for the detailed list of new features and backward incompatible changes. It is not just a next major PHP version. This release is a result of the almost two year’s development journey. It is a very special accomplishment of the core team. However, this is not just a final release being brought out, it is the rise of a new PHP generation with an enormous potential.

Will the PHP work for you?
  • As web developers and hosts have experienced major compatibility issues in versions of 5.x, there are great expectations that those issues will be gone in version 7.
  • There are some additions, like Abstract Syntax Tree (AST). One can use AST to compile better performing opcodes.
  • A Uniform Variable Syntax (UVS) will also be included in this new release. It aims to solve numerous inconsistencies during evaluation, like calling closures that are assigned to properties with the ($object->closureProperty)()or the ability to chain static calls to the server like:
class foo {static $bar = 'baz';}
classbaz {static $bat = 'Hello World';}

baz::$bat = function () {echo "Hello World";};

$foo = 'foo';
  • With the UVS, the name key of the property will be accessed by the $obj->$properties['name']with the name key of the property that is inside the $properties.
  • Memory savings will be coupled with better optimization of internal data structures.
  • Version 7 will be quicker and will let smaller hosts work with the same hardware they currently use.
  • Many Backwards Incompatible Changes are also being introduced. This can help that the code compiles better.
  • The POSIX compatible regular expressions extension, ext/eregandext/mysqlextension have been removed.
  • The ASP and various script tags have been removed, which means that <% and <%=, or <script language="php”>cannot be used anymore.
Is it worth it?
The answer is yes! An upgrade is always better!
  • PHP 7 will introduce a brand new operator <=> which is also called, Spaceship Operator. It can be used for comparisons when sorting through the data.
  • Version 7 will also help PHP developers to return a function with the kind it is expected to return like Type Hints.
  • As it is based upon the PHPNG project, which is powered by Zend, it can speed up PHP applications by at least 25% in real-world apps. You are not obliged to change any line of code for this.
  • With PHPNG in force, a normal WordPress homepage that required approximately 9.4 billion CPU instructions to execute will now execute in just 2.6 billion CPU instructions.
PHP 7 is the future of PHP. The web hosts have been waiting for this upgrade for quick a long time.