What’s New in PHP 8.3: A PHP Developer’s Perspective

What’s New in PHP 8.3: A PHP Developer’s Perspective

As a PHP developer, staying up to date with the latest improvements in the language is crucial for writing cleaner, faster, and more secure code. With the release of PHP 8.3, we’re seeing some exciting new features and enhancements that can improve both performance and developer experience. Let’s explore the most notable changes in PHP 8.3.

1. Readonly Class Properties Redefined

In PHP 8.1, readonly properties were introduced, allowing us to create immutable objects. PHP 8.3 takes it further by allowing readonly classes, which means all properties of a class are readonly by default:


readonly class Config {
public string $appName;
public int $version;
}

This makes the intent of immutability clearer and helps reduce boilerplate code.

2. Typed Class Constants

PHP 8.3 finally allows type declarations on class constants, bringing them in line with properties and method parameters:

class Status {
public const string ACTIVE = 'active';
public const int TIMEOUT = 30;
}

This improves code clarity and enforces stricter type safety.

3. Dynamic Class Constant Fetch

A long-awaited improvement: now you can use expressions to access class constants dynamically:

$class = MyClass::class;
$constant = 'STATUS';
echo $class::{$constant};

This opens the door for more flexible code, especially when working with meta-programming or dynamic APIs.

4. New json_validate() Function

One small but powerful addition: json_validate() allows developers to quickly check whether a string is a valid JSON:

if (json_validate($input)) {
// Safe to decode
}

This is more efficient than json_decode() with error checking and is a welcome tool for APIs and data handling.

5. Improved Randomizer API

The Random\Randomizer class (introduced in 8.2) has been enhanced further, making it easier to generate cryptographically secure random values with better control:

</p>
<p data-start="2106" data-end="2271">$rng = new \Random\Randomizer();
echo $rng->getInt(1, 100);</p>
<p data-start="2106" data-end="2271">

This brings PHP’s random number generation closer to modern standards used in security-sensitive applications.

6. Deprecations and Cleanups

Some legacy behaviors have been deprecated, such as:

  • Passing negative values to string functions like str_pad()

  • Calling get_class() with no arguments

  • Using octal numbers without the 0o prefix (now discouraged)

Staying alert to these changes helps future-proof your applications and keeps your codebase clean.

Final Thoughts

PHP 8.3 continues the trend of making PHP more modern, safer, and developer-friendly. With each release, it becomes more clear that PHP is not “just a scripting language” — it’s a powerful tool that continues to evolve with the needs of today’s developers.

As a PHP developer, I’m excited to start using these features in production. If you haven’t upgraded yet, now is a great time to test your codebase on PHP 8.3 and start leveraging the improvements.

Happy coding!

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *