This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

[LIVE WEBINAR] Don't fear downtime during a traffic surge! Discover the power of Autoscale on 28th Sept. Register Now →

What’s New in PHP 8.3?

Updated on September 8, 2023

6 Min Read
php 8.3

With each new release, PHP continues to empower developers with tools that streamline their workflows, improve code quality, and enhance application performance. PHP 8.3 is no exception. Packed with a plethora of exciting updates and additions, PHP 8.3 is poised to redefine how developers craft web applications.

Join us as we uncover the gems within PHP 8.3, exploring how these new features can empower developers to create exceptional web applications while keeping up with the ever-evolving landscape of modern programming.

Unleash the Power of PHP: Lightning-fast Hosting, Seamless Performance.

Experience the seamless blend of power, reliability, and simplicity that makes Cloudways the go-to choice for PHP hosting enthusiasts worldwide.

PHP 8.3 Release Timeline: When Can You Expect the Latest Upgrade

Release Date Type
June 8, 2023 Alpha 1
June 22, 2023 Alpha 2
July 6, 2023 Alpha 3
July 18, 2023 Feature freeze
July 20, 2023 Beta 1
August 03, 2023 Beta 2
August 17, 2023 Beta 3
August 31, 2023 RC 1
September 14, 2023 RC 2
September 28, 2023 RC 3
October 12, 2023 RC 4
October 26, 2023 RC 5
November 9, 2023 RC 6
November 23, 2023 GA

PHP 8.3: New Features

Typed Class Constants for Enhanced Code Integrity

PHP 8.3 introduces a powerful feature – Typed Class Constants – designed to elevate code reliability by enforcing strict data type declarations for class constants. This article explores the significance of Typed Class Constants, their implementation, and the positive impact they bring to PHP development.

class PaymentMethods {

const CREDIT_CARD: string = 'credit_card';

const PAYPAL: string = 'paypal';

const BANK_TRANSFER: string = 'bank_transfer';


JSON Validation with the New json_validate() Function

The json_validate() function is a new addition to PHP’s JSON extension in version 8.3. It enables developers to efficiently validate JSON strings against predefined schemas, ensuring data accuracy and consistency. This function simplifies the validation process, reducing the complexity and potential errors associated with custom validation routines.

$jsonData = '{"name": "John", "age": 30, "email": "[email protected]"}';

$jsonSchema = '{"type": "object", "properties": {"name": {"type": "string"}, "age": {"type": "integer"}, "email": {"type": "string", "format": "email"}}}';

if (json_validate($jsonData, $jsonSchema)) {

echo "JSON data is valid!";

} else {

echo "JSON data is invalid.";


Dynamic Class Constants and Enum Member Fetch Support

class constants have been defined with fixed values that cannot be computed at runtime. PHP 8.3 introduces Dynamic Class Constants, allowing developers to assign values to class constants based on expressions. This dynamic nature brings newfound versatility and adaptability to class constants.

enum Status: string {

case PENDING = 'pending';

case APPROVED = 'approved';

case REJECTED = 'rejected';


$status = Status::fetch('approved');

echo $status;  // Output: "approved"

Enhancing Garbage Collection Insight with gc_status()

The gc_status() function is a new addition to PHP’s Garbage Collection mechanism. It provides detailed information about the state of the garbage collector, including collection statistics, memory usage, and collection cycles. This invaluable data equips developers with the knowledge needed to optimize memory management.

$gcStatus = gc_status();

echo "Total collected cycles: " . $gcStatus['cycles'];

echo "Memory usage before collection: " . $gcStatus['memoryUsageBefore'];

echo "Memory usage after collection: " . $gcStatus['memoryUsageAfter'];

New \Random\Randomizer::getBytesFromString method

The \Random\Randomizer::getBytesFromString method is introduced as part of the Random extension. This method allows developers to obtain secure random bytes from a given string, providing a versatile and customizable approach to random data generation.

use \Random\Randomizer;

$seed = "mySecretSeed";

$randomBytes = Randomizer::getBytesFromString($seed, 32);

// $randomBytes now contains 32 secure random bytes derived from the seed

New \Random\Randomizer::getFloat() and nextFloat() methods

\Random\Randomizer::getFloat() and nextFloat():

In PHP 8.3, the \Random\Randomizer::getFloat() method and its counterpart nextFloat() are introduced as part of the Random extension. These methods allow developers to obtain high-precision random floating-point numbers within a specified range, enhancing the accuracy of random data.

Using \Random\Randomizer::getFloat() involves providing a minimum and maximum value, and the method generates a random floating-point number within that range.

use \Random\Randomizer;

$min = 0.0;

$max = 1.0;

$randomFloat = Randomizer::getFloat($min, $max);

Fallback value support for PHP INI Environment Variable syntax

the PHP INI Environment Variable syntax is enhanced to support fallback values. This means that developers can now define a default value for an environment variable, ensuring that the application functions correctly even if the environment variable is not explicitly set.

Developers can define a fallback value for an environment variable using the syntax $_ENV[‘VARIABLE_NAME’] = $_ENV[‘VARIABLE_NAME’] ?? ‘fallback_value’;. This syntax checks if the environment variable is already set; if not, it assigns the specified fallback value.

$_ENV['DATABASE_HOST'] = $_ENV['DATABASE_HOST'] ?? 'localhost';

PHP CLI Lint (php -l) supports linting multiple files at once

The PHP CLI (php -l) gains the ability to perform linting on multiple PHP files within a single command. This enhancement allows developers to efficiently validate the syntax of numerous files, simplifying the linting process and saving time.

developers can pass a list of file paths as arguments to the php -l command. The CLI then sequentially checks each file for syntax errors and provides concise feedback.

php -l file1.php file2.php file3.php

class_alias() supports aliasing built-in PHP classes

In PHP 8.3, the class_alias() function gains the ability to alias built-in PHP classes, which was not possible before. This enhancement empowers developers to create custom names for standard PHP classes, enhancing code readability and maintainability.

Using class_alias() to alias a built-in PHP class involves specifying the desired alias and the original class name as arguments. Once aliased, the original class can be referenced by its alias throughout the codebase.

class_alias(\DateTime::class, 'MyDateTime');

$customDateTime = new MyDateTime();

New stream_context_set_options function

In PHP 8.3, the stream_context_set_options() function becomes a powerful tool for fine-tuning stream contexts. This function enables developers to dynamically modify context options, empowering them to adapt and optimize stream operations as needed.

$context = stream_context_create([

'http' => [

'method' => 'POST',

'header' => 'Content-type: application/json',

'content' => json_encode(['key' => 'value']),



stream_context_set_options($context, [

'http' => ['timeout' => 10],


PHP 8.3: Deprecations & Changes

Adapting to get_class() and get_parent_class() Changes

In PHP 8.3, calling get_class and get_parent_class functions without parameters is deprecated. In PHP 9.0 the functionality allowing for the existence of multiple versions of a function with differing parameters will be eliminated. This means that if you don’t provide the $object parameter, you will get an error called ArgumentCountError.

class Test {
   public function __construct() {
       echo get_class($this);

get_parent_class() works the same way as get_class by passing value to $this
The function get_parent_class() gives us the same result as the parent::class when we use it without any arguments. We can replace function calls like this with parent::class constant.

class Test extends BaseTest{
   public function __construct() {
       echo get_parent_class($this);

unserialize(): Upgrade E_NOTICE errors to E_WARNING

Before PHP 8.3, if you gave an incorrect string to the unserialize() function, PHP would show notices (E_NOTICE) in some cases, like when there were syntax errors in the string.

PHP version 8.3 introduced the display of warnings (E_WARNING) to signify the change. Additionally, some error conditions of the serialize() function have been modified to also show a warning message called E_WARNING.

The following three error conditions that previously emitted an E_NOTICE are changed to emit E_WARNING since PHP 8.3:

  • Syntax errors (sometimes caused by incorrect serialization handlers) in the passed string
  • Failures in the custom unserialize handlers using __unserialize magic method; e.g the __unserialize() method not returning any value
  • Returning the same variable twice from __sleep() magic method causing a name clash

highlight_file and highlight_string output HTML changes

PHP 8.3 brings several changes to how the highlighter process white-spaces, and now wraps the output with a <pre></pre> HTML tag. Further, it no longer converts new-line characters to HTML <br /> tags, resulting in a multi-line highlighted HTML output.

Granular DateTime Exceptions

Before PHP 8.3, the Date/Time extension used standard \Exception and \Error.

In PHP 8.3, the Date/Time extension introduces extension-specific and granular Exception and Error classes to better receive and prompt the error and exception states. This will make it easier for cleaner to catch date-specific exceptions.

The new Exception/Error classes are added on top of the existing Error and Exception classes. This means that if your code already catches any Exception or Error exceptions, it will still catch these new errors as well.

How to Upgrade to the Latest PHP Version Cloudways

You can easily upgrade your current PHP version to the latest version on Cloudways by following the steps below:

  • Login to the Cloudways Platform.
  • Select your server.
  • You’ll be redirected to the Server Management page.
  • Click Settings & Packages > Packages.

  • Select PHP 8.2 from the drop-down menu

  • Click Save.
  • That’s how easily you can upgrade your PHP version on Cloudways.

Note: PHP 8.3 hasn’t been officially released yet. Once PHP 8.3 is released and made available on the Cloudways platform, you can upgrade to PHP 8.3 by following the above steps.

Cloudways: Where PHP Hosting Meets Unrivaled Speed and Security.

Elevate Your PHP Projects with Cloudways: Where Speed Meets Simplicity. Take Your PHP Development to New Heights with Cloudways’ Hosting Solutions.

Final Words

The new features in PHP 8.3 may not be a strong reason to switch or upgrade, but there are some quality improvements that can make development process easier. Depending on how you use it.

If you choose to upgrade or move to PHP 8.3, we strongly advise you to review the official PHP documentation on for more information. And, if you are using outdated PHP and cannot switch to a newer version like PHP 8.3 when it becomes available, make sure to consider PHP LTS or migration services.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Inshal Ali

Inshal is a Content Marketer at Cloudways. With background in computer science, skill of content and a whole lot of creativity, he helps business reach the sky and go beyond through content that speaks the language of their customers. Apart from work, you will see him mostly in some online games or on a football field.


Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!


Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour
Unleash The Cloud.
Not Budgets.

For 4 Months +
Up To 30 Free Migrations

Cyber Week

Time Left In Offer
  • 0


  • 0


  • 0


  • 0


40% OFF

On All Plans