PHP is Getting Better

Learn how PHP is getting better with each version.

Performance improvement with subsequent versions

You’re probably already familiar with PHP 7.4 and later versions. The performance and syntax improvements in these versions are proof of the language’s continued improvement. PHP’s new short closure syntax (arrow functions), first-class callable syntax, and typed properties are all valuable for functional programming. In situations that warrant their usage:

  • Short closures reduce program code verbosity.

  • The first-class callable syntax makes shuttling functions with multiple arguments a more straightforward task.

  • Typed properties enforce strictness inside class contexts and enhance class code readability.

Note: Other features like preloading and the Foreign Function Interface (FFI) present performance improvements but may require finesse to operationalize.

Example

The code given below contains examples of some the new features in PHP:

  • A class with typed properties

  • An array filter operation using the array_filter method

  • An array concatenation through unpacking (works with arrays with string keys in versions 8.1 and newer)

Get hands-on with 1200+ tech skills courses.