PHP

PHP 8.4 Alpha 1 available now!

Let’s dive in to the testing release of PHP 8.4

The release of PHP 8.4 marks another significant milestone in the evolution of one of the web’s most widely used programming languages. Building on the robust foundation of its predecessors, PHP 8.4 introduces a variety of new features, performance enhancements, and improvements that aim to make development more efficient and enjoyable.

Please do not use PHP 8.4 Alpha 1 in production, this is an early testing release.

We have covered two exciting features in other posts, Array Inspection Functions and Property Hooks. Let’s now take a peek at some other goodies.

MB Functions

String functions like ltrim, rtrim, and ucfirst have existed for a long while now. PHP 8.4 now includes support for multibyte strings too, taking the same arguments as it’s basic string counterparts.

DateTime from a timestamp

Previously, creating a datetime object from a timestamp was fumbly and a little verbose. PHP 8.4 makes this easier with a createFromTimestamp method.

$timestamp = 1720694974;
$dt = DateTimeImmutable::createFromTimestamp($timestamp);
$dt->format("d/m/Y"); // 11/07/2024

Initialising a class without parenthesis

This one was always a bit silly, but previously you’d need to write something like (new Foo())->someMethod() to initialise and call a method immediately.

Now you can lose the initial parenthesis as new Foo()->someMethod().

Conclusion

PHP 8.4 comes with a good array of features and improvements, we have listed only a few of them here. For a more full breakdown, head over to the PHP page here and to download 8.4.0 Alpha 1, either the PHP repository or the Docker container available on Docker Hub.

Again, please do not use this in production systems.