As of today, customers on our cloud hosting platform and servers using the Hepsia Control Panel can enable PHP 8.3 on their sites for testing purposes.
With Hepsia’s option to assign different PHP versions to different hosts, they can run a test version of their site and check its compatibility with the latest PHP release.
NOTE: PHP 8.3 has been designated as ‘Release Candidate’, which means that while it hasn’t been officially released yet, it’s mostly ready for mainstream adoption. However, it isn’t recommended for production use.
What is new in PHP 8.3?
With every new version, PHP provides developers with tools that simplify their work processes, enhance the quality of their code, and improve the performance of their applications.
Although PHP 8.3 doesn’t have any major additions compared to PHP 8.1 and 8.2, it does a great job in cleaning up the language and streamlining the way developers build web applications.
Below is a quick list overview of some of the new additions to PHP 8.3:
A new json_validate() function for simplified validation
The new json_validate() function is aimed to be a less process and memory-intensive alternative to json_decode().
Developers can utilize this tool to validate JSON strings based on predefined schemas, ensuring the accuracy and consistency of data.
This functionality streamlines the validation process by reducing the risk of errors that may arise from custom validation procedures.
New Typed Class Constants for enhanced code integrity
This is a brand-new feature that enforces strict data type declarations for class constants.
You can now define the type of constants and it won’t have to be inferred by the value of the constant alone.
Dynamic Class Constants and Enum Member Fetch Support for enhanced adaptability
Class constants typically have predefined values that cannot be calculated during program execution.
In PHP 8.3, Dynamic Class Constants are introduced, enabling developers to assign values to class constants using expressions.
This new feature adds a dynamic aspect to class constants, enhancing their versatility and adaptability.
New methods in the Random extension for customized random data generation
PHP 8.3 introduces new methods to the “Random” extension, enhancing its flexibility and extensibility for operations involving random bytes.
This is especially useful for cryptographic secure pseudo-random number generation (CSPRNG). These new methods include:
- \Random\Randomizer::getBytesFromString method – it enables developers to generate secure random bytes from a given string, offering flexibility and customization for generating various randomized data, including short URLs;
- \Random\Randomizer::getFloat() and nextFloat() methods – they help developers obtain high-precision random floating values within a specified range, enhancing the accuracy of random data.
New #[\Override] attribute to maximize error prevention in code upgrades
The #[\Override] attribute is intended to denote instances where a child method overrides a parent method on purpose.
When employed, the PHP compiler will verify whether such a method exists in the parent class or any implemented interface. If the method is not found, a compile-time error will occur.
This particular feature can greatly benefit developers by preventing errors during code upgrades.
Negative indices in arrays
Prior to the release of PHP 8.3, when the first element in an array was negative, the second element would default to 0.
However, with the introduction of PHP 8.3, the second element will now default to the next negative value in the array.
To illustrate, if the first element was -8, the following element will be -7 instead of 0.
You can view the full list of new features and bug fixes in the latest PHP 8.3 release candidate here.
How to switch to the new PHP 8.3 (RC) version?
As mentioned earlier in this post, you can test your sites/applications compatibility with PHP 8.3 by enabling the new version on a test version of your website.
Here is how to do that in a few simple steps:
- Log into the Hepsia Control Panel;
- Navigate to the Advanced section, then go to the “PHP Settings” section and tap on the PHP version per host tab menu:
- Select the host you want to run the new version on and then select PHP 8.3 (RC) from the Choose e PHP version drop-down menu:
How to switch to the new PHP 8.3 version once it is officially released?
Once PHP 8.3 is released and made available on our platform, you can upgrade your entire account to PHP 8.3 by following the steps below:
- Log into the Hepsia Control Panel;
- Navigate to the Advanced section and then go to the PHP Settings section;
- Select PHP 8.3 from the Choose e PHP version drop-down menu:
***
PHP 8.3 introduces several important enhancements to improve the quality of development.
If you decide to make the transition to PHP 8.3, which is set to be officially launched on November 23, it is highly recommended that you thoroughly examine the official PHP documentation in order to gain a comprehensive understanding of the new features and the benefits they offer.