PHP 8.3: All About this New PHP Version

|
Background Gradient

PHP is always improving, and for the same reason, it is a prominent language used for web development today. PHP 8.3 is a new effort in the same row. Like other releases, it aims to refine code quality, enhance app performance, and revamp development workflows.

PHP 8.3 came out as planned on November 23 and brings many new stuff and improvements compared to PHP 8.2. Some of the changes in 8.3 could make your PHP coding easier and more efficient, helping you write code faster and with fewer mistakes. 

Interested in knowing what’s new in this release and what’s changed among PHP 8.3 features? Let’s get started without further ado.

What’s New in PHP 8.3?

PHP 8.3 is a major release. It brings in a bunch of new features, like specifying types for class constants, making it easier to clone read-only properties, and adding more options related to randomization. And, of course, it includes improvements to make things run faster, fixes for bugs, and just general tidying up.

Here’s a quick list of what’s new in PHP’s latest version.

Typed Class Constants

Declaring type for Constants was not allowed in PHP before. They were always assigned a particular value, and their type was decided as per that value. This inheritance-based implication prevented altering a Constant’s type when used in interfaces, abstract classes, or child classes.  

Things have changed in PHP 8.3. You can now specify the type of class constants, which includes constants in interfaces, traits, and enums. This helps ensure that developers stick to the intended type when declaring constants, reducing the chance of unintended changes.

Typed Class Constants

New #[\Override] Attribute

A class, extending its parent, overrides its parent class’s method (with the same name). 

Though mostly intentional, it may reason in error at times. A typo, late implementation in the parent class, or changed method name in the parent class may cause this error.

To help developers avoid this trouble, PHP 8.3 has a solution.

In PHP 8.3, a new feature is introduced called #[\Override] attribute. Developers can use this attribute to signal that a method is meant to override a method in the parent class. 

If the attribute is used, PHP will check during compilation to ensure the method exists in the parent class or an implemented interface with the same signature. If not, it will raise an error.

php 8.3,php 8.3 features,php 8,php latest version,php version 8.3 release date

A New json_validate() Function

Prior to PHP 8.3, validating a JSON string required passing it to json_decode() function. As per the flags provided to the function, there used to be errors or exceptions. 

This approach was fine until it was about small JSON structures. For large JSON structures, you may face running out of memory error before completing the validation process or even processing the structure.

With the release of PHP 8.3, you can use a new function called json_validate(). This new function is more robust and less susceptible to error. Read its full signature below:

function json_validate(string $json, int $depth = 512, int $flags = 0): bool

The above will help you spare some memory.

php 8.3,php 8.3 features,php 8,php latest version,php version 8.3 release date

Deep Cloning of readonly Properties

In PHP 8.1, readonly properties were introduced, followed by readonly classes in PHP 8.2. One challenge that emerged was when cloning objects. If a value was set in the original object, trying to overwrite it in the clone would result in an error unless the reflection API was employed to override the readonly property.

In PHP 8.3, you now have the flexibility to re-declare or unset readonly properties while working within the __clone() method or a method called within __clone().

php 8.3,php 8.3 features,php 8,php latest version,php version 8.3 release date

A new mb_str_pad() Function

PHP has a function called str_pad() that adds extra characters (called padding) to the beginning, end, or both sides of a string until it reaches a specified length. But there’s a catch – it only works well with basic character setups and not so great with UTF-8 or other more complex character arrangements.

PHP 8.3 has come up with mb_str_pad() to overcome this shortcoming.

It works like str_pad() but with a few changes. 

For example, you can use multi-byte strings for both the string to pad and the padding string. 

Also, it automatically uses the encoding of the string to pad, but you can also choose a specific encoding if needed.

Support to Multiple Files at Once in PHP-CLI Linter

PHP CLI Lint (php -l) now lets you check the syntax of multiple files in one go. With this improvement, developers can validate the syntax of several PHP files at once using a single command. By providing a list of file paths as arguments to the php -l command, the CLI checks each file for syntax errors one after another, giving developers quick and clear feedback.

php 8.3,php 8.3 features,php 8,php latest version,php version 8.3 release date

Other Important Updates in PHP 8.3

We covered a few major features added to PHP with this new release. However, the release has a lot more to talk about. So, here is a quick list of a few more essential updates:

  • Dynamic Fetching of Class Constants and Enum Members
  • Introduction of a new method getBytesFromString() 
  • New getFloat() and nextFloat() Methods
  • New functions added to PHP, such as, socket_atmark() ldap_connect_wallet(), and ldap_exop_sync().
  • New ZipArchive::getArchiveFlag() and ReflectionMethod::createFromMethodName() method.
  • New str_increment(), str_decrement(), and stream_context_set_options() functions.
  • New posix_sysconf(), posix_fpathconf(), posix_pathconf(), and posix_eaccess() functions.

Deprecations in PHP 8.3

With many new additions, as enlisted above, PHP 8.3 also has a few depreciations and backward compatibility breaks. Here are a few noticeable ones:

  1. The constant U_MULTIPLE_DECIMAL_SEPERATORS is deprecated and replaced by U_MULTIPLE_DECIMAL_SEPARATORS.
  2. The MT_RAND_PHP Mt19937 variant is no longer available for use.
  3. ReflectionClass::getStaticProperties() is cannot be nulled anymore.
  4. The INI settings assert.active, assert.bail, assert.callback, assert.exception, and assert.warning are deprecated.
  5. The use of get_class() and get_parent_class() without arguments is deprecated.
  6. SQLite3 now defaults to using exceptions for error handling

There are modifications in Date/Time exceptions, range() function, and redeclaration of static properties in traits too.

PHP version 8.3 Download Link →

Is it Essential to Migrate My WordPress Site to PHP 8.3?

Well, in one word – Yes.

For any website, plugin, theme, or application built upon WordPress or any PHP-based CMS, it is strongly recommended to upgrade to 8.3 at the earliest. Doing so will help you in multiple ways. For your WordPress product, it will ensure:

  • Better performance
  • Faster speed 
  • Support from the PHP team and in the forums
  • Security
  • Compatibility and future-readiness

Considerations When Migrating to PHP 8.3

With the numerous deprecations and changes introduced in PHP 8.3, development teams should carefully examine their codebase when planning migration or upgrade. You can refer to this official guide while you migrate from PHP version 8.2 to 8.3. 

Upgrading from older versions needs to be done more carefully than anything.

No matter what, always test your site with PHP 8.3 in a sandbox environment before you make changes to live. The consequences of directly updating a WordPress or WooCommerce site could be daunting.

InstaWP Supports PHP 8.3 Already

Considering a migration to PHP 8.3 from older versions? InstaWP is your reliable companion, making the transition smoother and more manageable.

As promoting secure development is our priority, the tool supports building sites with the latest PHP version. You can build sites with the PHP version set to 8.3, as well as upgrade your existing site’s version to 8.3 and test it better using InstaWP’s capabilities.

Build WordPress Sites using PHP 8.3 with InstaWP

When you create a site using InstaWP, you can choose your site’s PHP version. 

php 8.3,php 8.3 features,php 8,php latest version,php version 8.3 release date

Select 8.3 as your choice, and follow this guide to building WordPress website. You will have a fresh WP instance, with PHP 8.3 enabled on it, ready for use. 

Use the Magic Login button or site credentials to access this website.

Testing PHP 8.3 with your WordPress Site

Want to test the PHP version 8.3 install with your existing website? That’s easy with InstaWP.

Use the InstaWP Connect plugin to create a staging of your existing site, and once your website is added to the InstaWP dashboard, click on its name.

In the PHP Config tab, you will see an option to change the PHP version of your website.

php 8.3,php 8.3 features,php 8,php latest version,php version 8.3 release date

Update the version and save settings. Now, you can test if everything on your site is working fine or not. Push the changes to live once you know this update is not breaking anything for you. 

In the worst-case scenario, you will have to improve your website as per the updated PHP version and then go live. However, using a staging environment for this purpose will keep your live site intact from mishappenings.

Migrating your WordPress Site to PHP 8.3 using InstaWP

InstaWP can simplify your PHP 8.3 migration journey. It offers a robust set of features to facilitate testing, coding, database management, and troubleshooting. 

With InstaWP, your transition to PHP 8.3 becomes a well-orchestrated process, ensuring that your WordPress site is up-to-date and performing optimally. Here’s how it can support you during migration:

  • Testing Environment: InstaWP provides a hassle-free staging environment for testing your PHP 8.3 migration. You can effortlessly set up a staging site, ensuring that your live site remains operational during the testing phase.
  • Code Editor: With InstaWP’s built-in code editor, making necessary code adjustments for PHP 8.3 compatibility becomes a breeze. Developers can edit files directly within the platform or try the VS Code integration for a familiar coding environment.
  • Database Editor: Migrating to PHP 8.3 may necessitate database updates. InstaWP simplifies this process with a user-friendly database editor service. Use the tool’s built-in DB Editor to esily manage database changes and configurations for a seamless migration.
  • Logs Viewer: PHP upgrades can sometimes lead to unforeseen issues. InstaWP’s logs viewer allows you to troubleshoot effectively, pinpointing any errors or glitches that may arise during the migration process.
  • 2-Way Sync for Controlled Rollouts: InstaWP’s 2-way sync feature offers a controlled approach to migration. With it, you can test your live site’s PHP 8.3 compatibility in the staging environment. When confident, proceed to synchronize changes to the live site with just a few clicks. You need to use the InstaWP Connect plugin for this.
  • SSH/SFTP Support for Secure Access: Security is paramount during migration. InstaWP supports SSH/SFTP, providing secure access to your WordPress site. Safeguard sensitive information and configurations as you transition to PHP 8.3.

A Word of Caution for Plugin and Theme developers

If you have developed a WordPress plugin or theme, it is essential that you start supporting PHP 8.3 as soon as possible.

Not supporting the latest version of PHP or WordPress will make new users avoid downloading your WordPress product. The existing users may also consider replacing your plugin/theme with a rival tool, considering the security risks an outdated solution possesses.

Considering the above, upgrade and test your WordPress plugin/theme and release a version that is compatible with the latest version of PHP.

Suggestion: If your plugin is in the WordPress.org repository, you can install the InstaWP Launcher extension on your Chrome browser. It’ll let you create a staging site (using PHP v8.3) with your WordPress themes and plugins installed on it, giving you a ground to get started with testing and code modification.

Can’t download InstaWP’s Chrome Extension? Use this download link to get it manually. Read this blog post to know why it’s unavailable.

Conclusion

In this blog post, we walked through the PHP version 8.3 release date, major additions, modifications, and depreciations related to PHP 8.3. To have a look at the complete list of PHP v8.3 updates, you can view the official release changelog using this link.

The point to note here is that PHP will continue to evolve. To leverage its full potential and keep your site updated & secure, you must update your site to the latest version, too. 

Remember, this should never be done without proper testing in a staging environment. So, create staging of your site in your InstaWP dashboard, upgrade your site’s PHP version, test everything well, and then only push the changes to your live site. It will ensure that your site only benefits from this update, and there is no harm to it.

Vikas Singhal

Founder, InstaWP

Vikas is an Engineer turned entrepreneur. He loves the WordPress ecosystem and wants to help WP developers work faster by improving their workflows. InstaWP, the WordPress developer’s all-in-one toolset, is his brainchild.
Like the read? Then spread it…
Facebook
Pinterest
LinkedIn
Twitter
You might also like

Get $25 in free credits — start building today.

Create your first site and unlock all premium features today.

Request demo

Wondering how to integrate InstaWP with your current workflow? Ask us for a demo.

Contact Sales

Reach out to us to explore how InstaWP can benefit your business.