Benjamin Crozat The web developer life

PHP 8.3: new features (with RFCs) and release date.

Benjamin Crozat Benjamin Crozat2 minutes read

Before you start reading this article, did you know 76 persons subscribed to my newsletter?

Join them and enjoy free content about the art of crafting websites!

PHP 8.3: new features (with RFCs) and release date.
Table of contents

According to the preparation tasks list, PHP 8.3 will be released on November 23, 2023, after three alpha releases, three beta, and six release candidates.

PHP is an open-source project. Knowing what’s going on for the next version only takes a minute of research. For instance, this page lists all the accepted RFCs for PHP 8.3.

PHP 8.3 new features and changes

json_validate()

Instead of using json_decode() to validate a JSON string, you can now use json_validate(). According to its RFC, it also consumes fewer resources.

json_validate('{ "foo": "bar", }');
 
// Syntax error
echo json_last_error_msg();

As you can see, json_validate() returns a boolean, and you can fetch the error message with json_last_error() or json_last_error_msg() for more details.

Learn more: PHP RFC: json_validate

Improved unserialize() error handling

PHP 8.3 will allow better error handling when unserializing.

I’m not familiar with custom unserialization, but I’ll do my best to explain how this RFC works in the simplest way possible.

Until now, we had to rely on horrible code where we had to set a custom error handler before calling the unserialize() function.

try {
set_error_handler(static function ($severity, $message, $file, $line) {
throw new ErrorException($message, 0, $severity, $file, $line);
});
 
$result = unserialize($serialized);
} catch (Throwable $e) {
// Unserialization failed. Catch block optional if the error should not be handled.
} finally {
restore_error_handler();
}

In PHP 8.3, we’ll be able to handle errors directly in our __unserialize() magic method:

function unserialize(string $data): mixed
{
try {
//
} catch (Throwable $e) {
throw new UnserializationFailedException(previous: $e);
}
}

Learn more: PHP RFC: Improve unserialize() error handling


That’s it for PHP 8.3 so far. 👍

I will report every new accepted RFC in the coming months!

Subscribe to my newsletter and follow me on Twitter to make sure you don’t miss anything!

Other posts to read

Laravel Dropbox Driver is a new storage you can add to your Laravel application and use it for all sorts of things.

Hiring a good developer can be challenging. But if you follow these tips and you will be able to hire the right fit for your projects.

Choose your web hosting provider and deploy your next Laravel project quickly and without any DevOps cost.

Whether PHP is dead or not is a matter of numbers, not opinions. I will provide you with essential statistics that will lead you to make better decisions.

Are you looking for the best web hosting for Laravel projects and all budgets? I've got you covered. Here are the best I found.

Redirects in PHP are simple. I will guide you step by step and show you how to dodge some traps. Finally, we'll learn the nuance between 301 and 302 redirects.

When in doubt, clear the cache. In this article, you'll learn about how to clear every cache Laravel uses.

Learn why the "Using $this when not in object context" error happens, and let me show you the only way to fix.

Here's a case study for my blog in the programming niche, where I share everything I did to increase clicks by a huge amount since the beginning.

Migrations are essential in any Laravel app using a database. I will tell you what they are, why you should use them and how you can generate them.