PHP 7

PHP 7 gets its foundations from an experimental PHP branch that was originally named phpng (PHP next generation), which aims at optimizing PHP performance by refactoring the Zend Engine while retaining near-complete language compatibility. As of 14 July 2014, WordPress-based benchmarks, which serve as the main benchmark suite for the phpng project, show an almost 100% increase in performance. Changes from phpng are also expected to make it easier to improve performance in the future, as more compact data structures and other changes are seen as better suited for a successful migration to a just-in-time (JIT) compiler. Because of the significant changes, this reworked Zend Engine will be called Zend Engine 3, succeeding the Zend Engine 2 used in PHP 5.

Because of phpng’s major internal changes, it would have to go into a new major version of PHP, rather than a minor 5.x release, according to PHP’s release process, thus spawning PHP 7. Major versions of PHP are allowed to break code backwards-compatibility, and so PHP 7 presented an opportunity to make other improvements beyond phpng that require backwards-compatibility breaks. In particular, the following backwards-compatibility breaks were made:

Many “fatal” or “recoverable”-level legacy PHP “errors” were replaced with modern object-oriented exceptions

The syntax for variable dereferencing was reworked to be more internally consistent and complete, allowing the use of ->, [], (), {}, and :: operators with arbitrary meaningful left-hand-side expressions

Support for legacy PHP 4-style constructor methods was deprecated

The behaviour of the foreach statement was changed to be more predictable

Constructors for the few classes built-in to PHP which returned null upon failure were changed to throw an exception instead, for consistency

Several unmaintained or deprecated SAPIs and extensions were removed from the PHP core, most notably the legacy mysql extension

The behaviour of the list() operator was changed to remove support for strings

Support for legacy ASP-style PHP code delimeters (<% and %>,) was removed

An oversight allowing a switch statement to have multiple default clauses was fixed

Support for hexadecimal number support in some implicit conversions from strings to number types was removed

The left-shift and right-shift operators were changed to behave more consistently across platforms

Conversions between integers and floating point numbers were tightened and made more consistent across platforms

PHP 7 also includes new language features. Most notably, it introduces return type declarations for functions, which complement the existing parameter type declarations, and support for the scalar types (integer, float, string, and boolean) in parameter and return type declarations.

Leave a Reply

Your email address will not be published. Required fields are marked *