PHP Releases Fibers
As a major new update to PHP, version 8.1 introduced several new features to improve the platform while restricting certain functionalities that are considered undesirable. The modern incarnation encourages defensive programming and is a continuation of PHP’s progress in providing type system improvements. This article will explore Fibers and how this functionality will help improve PHP usage going forward.
What Else is New in PHP 8.1?
In addition to Fibers, PHP 8.1 also provides users with multiple other new technologies, including Enums and Type System Improvements. Enums, or Enumerations, is an enumerated type that allows for a fixed number of possible values. One analogy that most people find helpful when talking about Enums is the different suits found in a deck of cards; with PHP 8.1, suits can be enumerated with an Enum.
Among the Type System Improvements, PHP 8.1 also now supports Intersection Types – effectively allowing the declaration of a parameter, property, or return type and the enforcement of any values that belong to a declared class or interface type. This contrasts Union Types found in PHP 8.0, which allow any declared types. PHP 8.1 focuses on “pure” Intersection Types since Union Types, and Intersection Types aren’t allowed in the same declaration.
One final update included in PHP 8.1 is a focus on new hashing algorithms. In this version, support has been added for MurMurHash3 and xxHash. These are among the fastest hashing algorithms, and they can efficiently process data at speeds nearly identical to traditional storage media. With this update, PHP is the first programming language to include these hashing algorithms in its standard library.