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.

✨ Vultr and Linode are back on Cloudways! VIEW PLANS→

PHP 8.2 Is Now Available on Cloudways (New Features, Deprecations, and More)

Updated on February 7, 2023

7 Min Read
php 8.2

On November 24, 2022, the highly anticipated PHP 8.2 was released to the delight of developers everywhere. With a focus on streamlining development and addressing persistent bugs, this latest version has quickly become the go-to choice for those seeking the ultimate PHP functionality.

Boasting a wealth of new features and improvements, as well as the deprecation of certain outdated features, PHP 8.2 is truly a game-changer. In this informative blog, we will delve into all the exciting updates included in this major release. We’ve got you covered, from new features to deprecations and everything in between.

Moreover, we’ll also cover the steps to upgrading your PHP version to 8.2 on Cloudways. Keep reading to learn more about this major release.

What’s New In PHP 8.2?

With every new release, PHP continues to evolve and bring a wealth of essential features to the table. And the latest addition, PHP 8.2, is no exception. Packed with a host of cutting-edge features and improvements, this version will take your website to the next level.

But that’s not all. By upgrading to the latest PHP version, you’re gaining access to new features, enhancing your site’s security, ensuring optimal syntax and execution, and maximizing your online potential. Here are some of the new features that PHP 8.2 has introduced:

Readonly classes

PHP 8.1 introduced readonly properties for classes, revolutionizing developer approaches. However, excessive typing was still a challenge.

PHP 8.2 solves this by allowing entire classes to be marked as readonly, making it easier for developers to use this feature. So, you can upgrade to PHP 8.2 for more efficient use of readonly properties.

readonly class MyClass {
public int $myProp;
public string $myOtherProp;
public __construct(string $myOtherProp, int $myProp)
{
$this->myProp = $myProp;
$this->myOtherProp = $myOtherProp;
}
}

Here we have a class defined as readonly. We have 2 properties of the class, and both of them are inherently readonly. Although the readonly rules from PHP 8.1 still apply, you can initialize the property once; after that, it is set.

$myObj = new MyClass(‘Cal was here’,42);

Once they are initialized, they get immutable.

$myObj->myProp = ‘Cal is no longer here’;

// Fatal Error: Uncaught Error: Cannot modify readonly property MyClass::myProp

The readonly class also prohibits dynamic property addition, ensuring unwavering stability. Remember that once a class is designated as readonly, it cannot be overridden at a certain point.”

New memory_reset_peak_usage Function

PHP 8.2 has brought a new function, memory_reset_peak_usage, which resets the highest memory usage recorded by memory_get_peak_usage. This function is ideal for monitoring memory utilization in multiple-cycle operations.

Null and False Standalone Types

In PHP 8.2, the false return type is accessible as a standalone sort instead of a union sort whenever an error occurs:

function alwaysFalse(): false
{
return false;
}

The same is true for the invalid type. For example, as a standalone type, NullPost::getAuthor() will be able to return it as null, unlike before. However, null, true, and false may be considered valid types on their own.

Stop Wasting Time on Servers

Cloudways handles server management for you to help you focus on creating great apps and keeping your clients happy.

Deprecate Partially Supported Callables

PHP 8.2 has deprecated the partially supported callables. Callables can be created using the $callable() syntax, the user_call_func(), or a function with a callback.

Passing these callables to the is_callable() function or using them with the callable parameter sorts won’t create the deprecation message. To understand the deprecation notice, developers can instead change over the parent, self, and inactive keywords in callable code to their particular class names utilizing the::class strategy.

New /n Modifier

PHP 8.2 has also incorporated the /n (no capture) modifier to the preg_* work family. When utilized, any groups with()meta-characters won’t capture anything separated from the named captured group. So, the result is the same as checking each group as non-capturing.

This change is because the modifier simplifies complex customary expressions for different groups. Instead of showcasing each group as non-capturing, developers can check all groups as non-capturing. At this point, developers can select and name specific bunches captured.

Deprecate ${} String Interpolation

There are different ways to embed variables in strings with PHP. However, PHP 8.2 has deprecated two methods.

"Hello, ${world}!";

Using ${} in strings is deprecated

"Hello, ${(world)}!";

Using ${} (variable variables) in strings is deprecated

However, these deprecations wouldn’t be a significant issue for developers as the two most well-known string addition methods will still work.

Other Minor Improvements

Along with new features, PHP 8.2 has also tweaked some existing features in the older PHP versions, including:

Random Extension Improvement

The pioneer PHP random number generator is still used within the base code. It’s never been great and completely useless for cryptographic uses.

PHP 7 introduced functions like random_int() and random_bytes(). They went a long way to fix the issues, but under the hood, these functions are interfaces to the local OS’s random number generator.

It was a great solution at the time but is very slow. But, with PHP 8.2, we get an extensible object-oriented interface rather than a completely modern Random number generator built into PHP.

Additional RFCs in PHP 8.2

PHP 8.2 also comes in with many new functions and minor changes: PHP 8.2 RFCs (Random Extension Improvement) is prepared to fix issues with a new curl_upkeep function to its Curl extension. It calls the curl_easy_upkeep() function in libcurl.

New ini_parse_quantity work: PHP INI directives acknowledge data sizes with a multiplier suffix. For instance, you can compose 25 Megabytes as 25M or 42 Gigabytes as just 42G. These postfixes are common in PHP INI files but are unprecedented somewhere else. This new function parses the PHP INI values and returns their data size in bytes.

New memory_reset_peak_usage work: This function resets the top memory utilization returned by the memory_get_peak_usage function. It is helpful when you’re running the same action multiple times and need to record each run’s peak memory utilization.

Nothing as Easy as Deploying PHP Apps on Cloud

With Cloudways, you can have your PHP apps up and running on managed cloud servers in just a few minutes.

Which Features Are Removed in PHP 8.2?

PHP 8.2 has introduced many new features but has also removed the support of MYSQLi with libmyql:

MySQLi Will No Longer Be Compiled With libmysql

Starting with PHP 8.2, MySQLi with libmysql won’t be supported, and the attempt to do so will result in a configuration error. In the past, PHP has supported two database libraries for interfacing that are MySQL databases: mysqlnd and libmysql.

As of PHP 5.4, MySQL has been the default library, and you can compile MySQLi through extensions. This won’t likely cause any critical issues for developers.

However, the two of the most significant features supported by libmysql that aren’t accessible with MySQLnd are supported, i.e., authentication and automatic reconnecting through LDAP and SASL.

How to Install PHP 8.2 on Cloudways

You can install PHP 8.2 on Cloudways in a breeze. Follow the steps below:

  • Sign up or log in to the Cloudways Platform.
  • Click Add Server.
  • Select PHP in the Application & Server details section.
  • Name your managed app and server.
  • Select your IaaS provider.
  • Choose server size and location.
  • Click the Launch Now button to start your 3-day free trial (no credit card required).

The GIF below visualizes the above steps:

DO installation

Wait for some minutes for your server to launch. Once it is launched, you’ll have the PHP 7.4 version set by default. But don’t fret; you can upgrade to PHP 8.2 almost instantly. Follow the steps in the next section.

How to Upgrade to PHP 8.2 on Cloudways

You can quickly upgrade your current PHP version to the latest 8.2 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.

change-php-version

  • You will see your current PHP version; click the edit button right next to it.
  • Select PHP 8.2 from the drop-down menu.

upgrade-PHP-8.2-on-cloudways

  • Click Save.

Ta-da! you will have your PHP version updated to 8.2 in no time.

Host PHP Websites with Ease [Starts at $10 Credit]

  • Free Staging
  • Free backup
  • PHP 8.0
  • Unlimited Websites

TRY NOW

Keep Your PHP Version Up to Date

PHP 8.2 elevates the already significant enhancements of PHP 8.0 and 8.1 to new heights, offering various exciting features. These include introducing a standalone type, read-only properties, and a host of execution optimizations.

Q. What is the difference between PHP 8.1 and 8.2?

A: PHP 8.1 introduced the readonly feature for class properties. But, PHP 8.2 will now let you declare not just the class properties but the entire class as readonly.

Q. What will be deprecated in PHP 8.2?

A: PHP 8.2 will deprecate the dynamic properties such as partially supported callables and String Interpolation.

Q. Why should I upgrade to PHP 8.2?

A: PHP 8.2 uses the parameters to access private information from the stack, making them more secure. Upgrading to the latest PHP versions speeds up your sites and strengthens their security. We recommend upgrading to PHP 8.2 to use the latest features and eliminate the bugs reported in the earlier versions.

Q. Is PHP 8.2 better?

A: The usage of PHP versions totally depends upon the user’s requirements. However, it is always recommended to keep your version upgraded to keep your website secure.

Q. What is the latest version of PHP 8?

A: PHP’s latest version is 8.2, released on November 24, 2022.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Shahzeb Ahmed

Shahzeb is a Digital Marketer with a Software Engineering background, works as a Community Manager — PHP Community at Cloudways. He is growth ambitious and aims to learn & share information about PHP & Laravel Development through practice and experimentation. He loves to travel and explore new ideas whenever he finds time. Get in touch with him at [email protected]

×

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

CYBER WEEK SAVINGS

  • 0

    Days

  • 0

    Hours

  • 0

    Mints

  • 0

    Sec

GET OFFER

For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now