New major version of PHP is under active development since over a year (including non-public rewrite called phpng) and obviously number of changes still increases. Therefore, I have decided to point out most of important things we can expect.
For this article, I will split them between new features and actions aimed at improving language consistency and cleaning up some rubbish accumulated over the past years.
Short explanation to begin with. The next version after PHP 5 will be PHP 7. The main reason is the fact that PHP 6 already existed and while it never reached stable state, there are many books and resources refering to its name. It was assumed that skipping this number will allow to avoid potential confusion.
The most notable change is huge speed improvement. Guys from Zend are doing awesome job refactoring Zend Engine and looking for new ways to make code execution faster. It results in even 50% boost in real-life applications, not in synthetic benchmarks.
It should be noted that new major version almost certainly will not bring us
highly-desired changes such as renaming functions to end with
needle, haystack problem once and for all. While it is technically possible,
PHP developers don't want to ruin their users' trust breaking too much BC and become
another Python 3 (if you know what I mean).
OK, enough talking, let's get down to the facts:
- Abstract Syntax Tree - this change is under the hood and don't have direct impact on userland code. However, it makes parsing code easier, more flexible and less error prone (it is obvious simplification of the subject, but you probably won't care about the details at this moment).
Null Coalesce Operator - new operator
??(known from some other languages) is introduced. The easiest explanation would be
$id = isset($_GET['id']) ? $_GET['id'] : 0;written as
$id = $_GET['id'] ?? 0;. Check the original RFC for more details.
Unicode Codepoint Escape Syntax - introduces syntax to
escape Unicode codepoint (e.g.
- Error call to a member function of a non-object is now catchable
unserialize()allows to either completely prohibit restoring objects or restrict the objects being restored to a whitelist of objects
mysql_*functions are no longer available by default, because
ext/mysqlhas been removed from core and will be moved to PECL
ereg_*functions) has been removed and will be migrated to PECL as well
- Uniform Variable Syntax - variable syntax in PHP 7 is more consistent and allows for more advanced expressions. This change introduces some backwards compatibility breaks in edge cases, but they can be avoided by using curly braces, so the code is parsed the same way in PHP 5 and 7. Click on the link to check real-life examples.
- Some inconsistences in handling integers on different platforms are fixed (more details)
- String support for
list()has been removed as it has been introduced unintentionally and might cause unexpected results (more details)
- Alternative PHP tags, namely
<%=(ASP tags) and
<script language="php">are removed
- Support for multiple default clauses in switch has been removed
- Support for comments indicated with
#in INI files has been removed
$is_dstparameter of the
gmmktime()functions has been removed
- Support for assigment of new by reference has been dropped (write
$obj = new ClassNameinstead of
$obj =& new ClassName)
e(eval) modifier for
preg_replace()has been removed.
preg_replace_callback()should be used instead
PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENTdriver option has been removed - more general
PDO::ATTR_EMULATE_PREPARESshould be used instead
SNI_server_namestream context options are removed
- Scoped calls of non-static methods from incompatible
$thiscontext are no longer supported (more details)
- Support for string category names in
setlocale()has been dropped (use
LC_*constant instead of e.g.
- Support for unsafe CURL uploads has been removed
- Following php.ini directives have been removed:
- Following functions are removed:
dl(on fpm-fcgi SAPI only, though),
Personally, I find all changes mentioned above a very good news for everyone interested in PHP development. More consistent language means less quirks to remember and allows to write code more effeciently.
Moreover, I think it's a great starting point for potential new features. Focusing on cleanup, internal and userland as well, is very important aspect, as the new major version is probably the only oportunity to do this in next about ten years.
Note: it is my first article written in English, so I would be very glad for being forgiving (in linguistic aspect, not meritorical, of course!) and pointing out eventual language mistakes.