When will php8 be released? PHP developers are looking forward to it very much. On June 25, 2020, the PHP team released the first test version Alpha1 (PHP 8.0.0), which heralds the official launch of the PHP8 release cycle!
The official PHP 8.0.0 first version release announcement is as follows:
PHP 8 Alpha version released, download address:
https://www.php.net/archive/2020.php
PHP 8 is a new major version that introduces some major changes, as well as many new features and performance improvements. Here is a brief introduction to some highlights:
JIT, Just-In-Time, just-in-time compilation
The feature that everyone is most concerned about is none other than JIT. This feature has been in development for many years and has survived the major version series of PHP 5 and 7 (the PHP 6 project was aborted). It was not until March last year that it was finally confirmed by voting that it would enter PHP 8.
JIT is a compiler strategy (refer to the article:What is PHP JIT? PHP8 new features JIT graphic and text explanation), it expresses the code as an intermediate state, during operation It is converted into architecture-dependent machine code and executed on the fly. In PHP, this means that the JIT treats instructions generated by Zend VM as intermediate representations and executes them in architecture-dependent machine code. That is to say, it is no longer Zend VM that hosts the code, but the underlying CPU. .
Although PHP performance has been significantly improved since PHP 7.0 by optimizing the core data structure HashTable, strengthening certain opcodes in Zend VM, and continuously improving the Optimizer component of OPCache, in fact these optimizations It seems to have reached its limit. Now JIT starts from the bottom and is considered to be the best way to improve PHP performance.
For the performance comparison after the introduction of JIT (and the overall performance of PHP 8), you can refer to this month's Phoronix benchmark test (note: the test was conducted using the source code build version at the end of May).
Union Types, union type
Union Types support Receives multiple values of different types. It is a collection of two or more types. You can choose one of them when using it. The use of union types is very common in standard libraries in the open source ecosystem, including PHP. PHP's support for union types will allow more type information to be migrated from phpdoc to function signatures. It can be said that after generics, union types are the biggest breakthrough in the current type declaration system.
Attributes, annotation
The Attributes here are Annotations (annotations) in other languages provide a way to add metadata to a class without parsing the documentation block.
Learn more:PHP8 new features: Attributes
New static Return type
Although it is possible to return self, considering the nature of PHP's dynamic type, it will be more efficient to support static return types in PHP 8. Should be very useful to many developers.
WeakMap, weak mapping
WeakMaps allow creation from Mapping of objects to arbitrary values (similar to SplObjectStorage) without preventing garbage collection of the object used as the key. As long as the object is added to the WeakMap, the GC can reclaim the memory occupied by it when the condition is triggered.
In PHP 7.4, support for WeakReference (weak reference) has actually been introduced. However, raw weak references by themselves have limited use, and weak mappings are more commonly used in practice. Since there is no functionality provided to register a destruction callback, it is not possible to implement an efficient weak mapping on top of PHP weak references. A general use case for weak mapping is to associate data with individual object instances without forcing them to remain active, avoiding long-running processes needlessly occupying memory.
Regarding WeakMap/WeakReference, you can refer to the WeakRef part of this article. Although it is about JS, the principles are the same:
https:/ /www.html.cn/web/javascript/19449.html
For more related features, you can view:
In addition, I also noticed several features that are in the voting stage (that is, they may be incorporated into a certain version soon), such as match expression (match expression) and the use of @@ or #[] instead of < ;>’s proposals are worthy of attention:
It should be noted that PHP 8 is a major update version with some major changes, so it is best to check the UPGRADING document for related matters. In reality, however, many of these breaking changes were already introduced in previous 7.* versions, so if you've been keeping up to date, upgrading to PHP 8 won't have much impact.
The success of PHP 8 is the second JAVA, and a large number of developers from other languages will return to the PHP camp! It’s quick and easy after all! Let’s look forward to it together!
[Related recommendations]