PHP 7[edit]
During 2014 and 2015, a new major PHP version was developed, which was numbered PHP 7. The numbering of this version involved some debate.[44] While the PHP 6 Unicode experiment had never been released, several articles and book titles referenced the PHP 6 name, which might have caused confusion if a new release were to reuse the name.[45] After a vote, the name PHP 7 was chosen.[46]
The foundation of PHP 7 is a PHP branch that was originally dubbed PHP next generation (phpng). It was authored by Dmitry Stogov, Xinchen Hui and Nikita Popov,[47] and aimed to optimize PHP performance by refactoring the Zend Engine while retaining near-complete language compatibility.[48] As of 14 July 2014, WordPress-based benchmarks, which served as the main benchmark suite for the phpng project, showed 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.[49] Because of the significant changes, the reworked Zend Engine is called Zend Engine 3, succeeding Zend Engine 2 used in PHP 5.[50]
Because of major internal changes in phpng it must receive a new major version number of PHP, rather than a minor PHP 5 release, according to PHP's release process.[51] Major versions of PHP are allowed to break backward-compatibility of code and therefore PHP 7 presented an opportunity for other improvements beyond phpng that require backward-compatibility breaks. In particular, it involved the following changes:
- Many fatal- or recoverable-level legacy PHP error mechanisms were replaced with modern object-oriented exceptions[52]
- The syntax for variable dereferencing was reworked to be internally more consistent and complete, allowing the use of the operators
->
,[]
,()
,{}
, and::
, with arbitrary meaningful left-side expressions[53] - Support for legacy PHP 4-style constructor methods was deprecated[54]
- The behavior of the
foreach
statement was changed to be more predictable[55] - Constructors for the few classes built-in to PHP which returned null upon failure were changed to throw an exception instead, for consistency[56]
- Several unmaintained or deprecated server application programming interfaces (SAPIs) and extensions were removed from the PHP core, most notably the legacy
mysql
extension[57] - The behavior of the
list()
operator was changed to remove support for strings[58] - Support was removed for legacy ASP-style delimiters
<%
and%>
and<script language="php"> ... </script>
[59] - An oversight allowing a switch statement to have multiple
default
clauses was fixed[60] - Support for hexadecimal number support in some implicit conversions from strings to number types was removed[61]
- The left-shift and right-shift operators were changed to behave more consistently across platforms[62]
- Conversions between integers and floating point numbers were tightened and implemented more consistently across platforms[62][63]
PHP 7 also included new language features. Most notably, it introduces return type declarations for functions[64] which complement the existing parameter type declarations, and support for the scalar types (integer, float, string, and boolean) in parameter and return type declarations.[65]
יום שישי, יולי 12, 2019