Hướng dẫn php 8.1 release schedule
Enumerations RFC DocPHP < 8.1 Show
PHP 8.1
Use enum instead of a set of constants and get validation out of the box. Readonly Properties RFC DocPHP < 8.1
__construct(Status $status) PHP 8.1
__construct(Status $status) Readonly properties cannot be changed after initialization, i.e. after a value is assigned to them. First-class Callable Syntax RFC DocPHP < 8.1
PHP 8.1
It is now possible to get a reference to any function – this is called first-class callable syntax. New in initializers RFCPHP < 8.1
__construct( PHP 8.1
__construct( Objects can now be used as default parameter values, static variables, and global constants, as well as in attribute arguments. This effectively makes it possible to use nested attributes. PHP < 8.1
PHP 8.1
Pure Intersection Types RFC DocPHP < 8.1
$value as $val) {
PHP 8.1
Use intersection types when a value needs to satisfy multiple type constraints at the same time. It is not currently possible to mix intersection and union types together such as Never return type RFC DocPHP < 8.1
redirectToLoginPage() { PHP 8.1
redirectToLoginPage(): never { A function or method declared with the Final class constants RFC DocPHP < 8.1
Bar extends Foo PHP 8.1
Bar extends Foo It is possible to declare final class constants, so that they cannot be overridden in child classes. Explicit Octal numeral notation RFC DocPHP < 8.1
PHP 8.1
It is now possible to write octal numbers with the explicit Fibers RFC DocPHP < 8.1
PHP 8.1
Fibers are primitives for implementing lightweight cooperative concurrency. They are a means of creating code blocks that can be paused and resumed like Generators, but from anywhere in the stack. Fibers themselves don't magically provide concurrency, there still needs to be an event loop. However, they allow blocking and non-blocking implementations to share the same API. Fibers allow getting rid of the boilerplate code previously seen with Array unpacking support for string-keyed arrays RFC DocPHP < 8.1
PHP 8.1
PHP supported unpacking inside arrays through the spread operator before, but only if the arrays had integer keys. Now it is possible to unpack arrays with string keys too. Performance ImprovementsSymfony Demo App request time The result (relative to PHP 8.0):
Performance related features in PHP 8.1:
New Classes, Interfaces, and Functions
Deprecations and backward compatibility breaks
|