<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/" >

<channel>
	<title>php 8.2 new features &#8211; RACKSET</title>
	<atom:link href="https://rackset.com/tag/php-8-2-new-features/feed" rel="self" type="application/rss+xml" />
	<link>https://rackset.com</link>
	<description></description>
	<lastBuildDate>Sun, 26 Jul 2026 14:59:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://rackset.com/wp-content/uploads/2025/01/cropped-Rackset-logo-512-32x32.png</url>
	<title>php 8.2 new features &#8211; RACKSET</title>
	<link>https://rackset.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Why You Need to Upgrade Your PHP to Latest Version?</title>
		<link>https://rackset.com/learn/server/why-you-need-to-upgrade-your-php-to-latest-version</link>
					<comments>https://rackset.com/learn/server/why-you-need-to-upgrade-your-php-to-latest-version#respond</comments>
		
		<dc:creator><![CDATA[rackset]]></dc:creator>
		<pubDate>Sun, 01 Jan 2023 08:56:11 +0000</pubDate>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Server Management & Monitoring]]></category>
		<category><![CDATA[How to update php version]]></category>
		<category><![CDATA[How to update php version in cPanel]]></category>
		<category><![CDATA[how to update php version in WordPress]]></category>
		<category><![CDATA[latest php version]]></category>
		<category><![CDATA[php 8.2 new features]]></category>
		<category><![CDATA[update php version cPanel]]></category>
		<category><![CDATA[upgrade php version linux]]></category>
		<category><![CDATA[why you need to upgrade to php 8.2]]></category>
		<guid isPermaLink="false">https://rackset.com/?post_type=blog&#038;p=6900</guid>

					<description><![CDATA[Regular updates to your site&#8217;s version of WordPress will ensure that your site will be at a high quality of performance and security. If you do not change your site&#8217;s PHP version, it&#8217;s leaving your site at risk of being hacked and potential bottlenecks in performance. It&#8217;s quite simple to verify your website&#8217;s PHP version [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Regular updates to your site&#8217;s version of WordPress will ensure that your site will be at a high quality of performance and security. If you do not change your site&#8217;s PHP version, it&#8217;s leaving your site at risk of being hacked and potential bottlenecks in performance.</p>
<p>It&#8217;s quite simple to verify your website&#8217;s PHP version and update it to the <strong>latest PHP version</strong>. This could lead to speedier loading times, better security, and the ability to support new features.</p>
<p>In this article, we’ll discuss how to update the PHP version, <strong>how to update the PHP version in cPanel and WordPress</strong> and why you should upgrade and use the <strong>PHP 8.2 new features on your <a href="https://rackset.com/server/vps-server/" target="_blank" rel="noopener">VPS server with PHP 8.2</a>.</strong></p>
<p>&nbsp;</p>
<h2>An Introduction to PHP</h2>
<p>PHP is an underlying scripting and programming language that plays a significant part in WordPress development (mainly). PHP retrieves information from databases and transforms the data into an HTML website page each time you have a visitor to your site.</p>
<p>If you&#8217;re a webmaster, you may not have to master PHP programming. After downloading WordPress, you&#8217;ll receive all your PHP files that comprise WordPress.</p>
<p>While these files were designed for you and are awaiting your content, themes and plugins, there are a few scenarios in which you could benefit from the editing of PHP files:</p>
<ul>
<li>    The creation of a custom theme or plugin</li>
<li>    Modifying the files on your server</li>
<li>    Connecting a site to a MySQL database</li>
</ul>
<p>Because PHP is among the primary languages used in WordPress, knowing an understanding of how to use it can broaden the possibilities of what you can work on.</p>
<p>Most likely, you won&#8217;t be required to edit any of your PHP files. However, understanding PHP can be useful for developers looking to develop new software or modify existing ones. Now, <strong>why do you need to upgrade to PHP 8.2</strong>?</p>
<p>&nbsp;</p>
<h2>Reasons Why You Should Update PHP Versions</h2>
<p>Take a look at the reasons below to look into updating your computer in case you haven&#8217;t yet.</p>
<p>&nbsp;</p>
<h3>1. Security</h3>
<p>One of the main reasons to upgrade to the <strong>latest PHP version</strong> is to ensure that you are using the newest features, which are maintained and patched frequently to fix security flaws. PHP 5.4 has not been patched since the year 2015. In addition, PHP 5.5 has not been updated since 2016. It is important to remember that some operating system manufacturers still patch earlier versions of PHP when they include it.</p>
<p>Based on CVE Details, 2016 was one of the most difficult times for PHP security vulnerabilities, with more than 100 vulnerabilities being identified. This included DoS and the execution of code, overflow memory corruption, director traversal, XSS, a bypass as well as gain types of information. The year 2017 was the third most harmed in the history of 2,000 and included more than 40 security holes.</p>
<p>&nbsp;</p>
<h3>2. Performance</h3>
<p>The release of PHP 7.2, 7.3, 7.4, 7.4 and 8.0 brought huge performance improvements! In fact, they were so big that it&#8217;s the top priority in lieu of small tweaks you may be playing with on your WordPress website. PHP 7 allows the system to run more than twice the number of requests per second, compared to PHP 5.6, which runs at nearly half the latency.</p>
<p>&nbsp;</p>
<h3>3. Support</h3>
<p>There is another explanation you should make use of the most recent as well as fully supported PHP versions. A lot of times, the designers of themes and plugins cannot extend support for earlier versions. The reason for this reason, is time-related and not having the time to check compatibility. It is inevitable that things will break when you use older versions of PHP. You can observe this happen first-hand on forums like WordPress forums. This is a typical error that is a result of an old PHP version and the way it handles a specific function:</p>
<p>&nbsp;</p>
<h3>4. New Features for Developers</h3>
<p>Many WordPress developers would rather develop on the latest versions of PHP should they be able to do so because there are a lot of new features developed in the time between PHP 5.2 to PHP 7.4.</p>
<p>&nbsp;</p>
<p>Read More: <a href="https://rackset.com/blog/whats-new-in-php-8-2-changes-and-updates/" target="_blank" rel="noopener">What’s New in PHP 8.2 – Changes and Updates</a></p>
<p>&nbsp;</p>
<h2>How to Update PHP Version in cPanel</h2>
<p>To <strong>update the PHP version in cPanel</strong>, there are two generic methods that we’ll go over.</p>
<p>&nbsp;</p>
<h3>Modify your PHP Version of a Domain within WHM</h3>
<p><img decoding="async" class="alignnone size-medium wp-image-6905" src="https://rackset.com/wp-content/uploads/2023/01/upgrade-php-version-using-cpanel.png" alt="how to upgrade php version in cpanel" width="" height="" /></p>
<ul>
<li>      Log in to WHM.</li>
<li>      Navigate to MultiPHP Manager</li>
<li>      Within the &#8220;User Domains&#8221; section, find your domain</li>
</ul>
<p>To the right of your domain&#8217;s address on the far right side, under the PHP Version column, select the drop-down menu and select the PHP Version for the domain you own.</p>
<p>&nbsp;</p>
<h3>Modify your PHP version of one or more domains within the cPanel</h3>
<ul>
<li>      Log in to cPanel.</li>
<li>      Navigate to MultiPHP Manager.</li>
</ul>
<p>Within the Set PHP Version per Domain section, Use the bar for searching to locate your domain name and select the checkbox on the left side of the domain&#8217;s name. (Do this for every domain that needs the identical PHP version.)</p>
<p>In the upper right corner section of the Set PHP Version per Domain section, you can click on the drop-down menu beside PHP Version and select the desired PHP version.</p>
<p>Click Apply to switch the PHP version of each of the domains to the chosen PHP version.</p>
<p>&nbsp;</p>
<h2>Old PHP Versions</h2>
<p>Like all pieces of software programs, PHP has a release timetable that it is required to follow so that it can keep working on improvements. Every major release of PHP is generally supportable for two years following the date of release. During this time, security and bugs are patched and fixed regularly.</p>
<p>&nbsp;</p>
<h3>PHP 5.6, 7.0, 7.1, and 7.2</h3>
<p>End-of-life implies that these versions won&#8217;t be supported by security and may be vulnerable to unpatched security flaws.</p>
<ul>
<li style="font-weight: 400;" aria-level="1">On November 30 in the year 2020, PHP 7.2 reached the final point of use.</li>
<li style="font-weight: 400;" aria-level="1">On the 1st of December 2019, PHP 7.1 was at the expiration date.</li>
<li style="font-weight: 400;" aria-level="1">On December 3, 2018, PHP 7.0 reached the expiration date.</li>
<li style="font-weight: 400;" aria-level="1">The day after Christmas in 2018, PHP 5.6 also reached its expiration date. This marks the conclusion of a period that was PHP 5, as the first version, 5.0, was launched 14 years ago.</li>
</ul>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>This is the perfect moment to consider using the <strong>latest PHP version</strong>, which is PHP version 8.2. As mentioned, nowadays, when you <a href="https://rackset.com/server/vps-server/" target="_blank" rel="noopener"><strong>buy a VPS hosting</strong></a> service, it automatically comes with the <a href="https://rackset.com/blog/whats-new-in-php-8-2-changes-and-updates/" target="_blank" rel="noopener"><strong>latest PHP 8.2 new features</strong></a> that you can take advantage of. In this article, we discussed how to update the PHP version and how to update the PHP version in WordPress.</p>
<div class="blogbutton"><a href="https://rackset.com/server/vps-server/" target="_blank" rel="noopener">Buy VPS Server with PHP 8.2</a></div>
<h2>Benefits of Upgrading Your PHP Version</h2>
<p>Upgrading to the latest PHP version can significantly enhance your website&#8217;s performance, security, and compatibility. Newer versions of PHP are optimized for speed, helping your website load faster and handle more requests efficiently. Additionally, they include critical security patches that protect against vulnerabilities.</p>
<ul>
<li><strong>Performance:</strong> Experience up to 3x faster execution times with the latest PHP versions.</li>
<li><strong>Security:</strong> Secure your site with the latest security updates and patches.</li>
<li><strong>Compatibility:</strong> Ensure compatibility with the latest frameworks and tools.</li>
</ul>
<h2>Steps to Upgrade Your PHP Version</h2>
<p>Follow these steps to upgrade your PHP version safely:</p>
<ol>
<li><strong>Backup Your Site:</strong> Always start by backing up your website files and databases.</li>
<li><strong>Check Compatibility:</strong> Ensure your code and plugins are compatible with the new PHP version.</li>
<li><strong>Update PHP:</strong> Use your hosting control panel or contact your hosting provider to switch to the latest PHP version.</li>
<li><strong>Test Your Site:</strong> Thoroughly test your website for any issues post-upgrade.</li>
</ol>
<h2>PHP Version Comparison Table</h2>
<table>
<thead>
<tr>
<th>PHP Version</th>
<th>Release Date</th>
<th>Key Features</th>
</tr>
</thead>
<tbody>
<tr>
<td>PHP 7.4</td>
<td>November 2019</td>
<td>Preloading, Typed Properties, Arrow Functions</td>
</tr>
<tr>
<td>PHP 8.0</td>
<td>November 2020</td>
<td>Just-In-Time Compilation, Union Types, Named Arguments</td>
</tr>
<tr>
<td>PHP 8.1</td>
<td>November 2021</td>
<td>Fibers, Readonly Properties, Improved Performance</td>
</tr>
</tbody>
</table>
<h2>FAQ</h2>
<h3>What is the latest PHP version?</h3>
<p>The latest stable PHP version is PHP 8.1, released in November 2021. It includes performance improvements and new features such as Fibers and Readonly Properties.</p>
<h3>How do I know if my PHP version needs upgrading?</h3>
<p>You can check your PHP version through your hosting control panel or by running a PHP script with <code>phpinfo()</code>. If your version is no longer supported, it&#8217;s time to upgrade.</p>
<h3>Can I upgrade PHP without affecting my website?</h3>
<p>Yes, by ensuring compatibility with your code and plugins before upgrading, you can minimize the risk of issues. Always backup your site and test thoroughly after the upgrade.</p>
<p>For seamless PHP upgrades and expert support, consider our <a href="https://rackset.com/hosting">managed hosting solutions</a> at Rackset.</p>
<p><script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "name": "What is the latest PHP version?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "The latest stable PHP version is PHP 8.1, released in November 2021. It includes performance improvements and new features such as Fibers and Readonly Properties."
      }
    },
    {
      "@type": "Question",
      "name": "How do I know if my PHP version needs upgrading?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "You can check your PHP version through your hosting control panel or by running a PHP script with phpinfo(). If your version is no longer supported, it's time to upgrade."
      }
    },
    {
      "@type": "Question",
      "name": "Can I upgrade PHP without affecting my website?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Yes, by ensuring compatibility with your code and plugins before upgrading, you can minimize the risk of issues. Always backup your site and test thoroughly after the upgrade."
      }
    }
  ]
}
</script></p>
<h2>Practical Steps for Upgrading PHP Version</h2>
<p>Upgrading your PHP version is crucial for maintaining the security and performance of your websites. Here are practical steps to ensure a smooth transition:</p>
<ul>
<li><strong>Backup Your Website:</strong> Before initiating the upgrade, create a full backup of your website&#8217;s files and database. This ensures that you can restore your site if anything goes wrong during the upgrade.</li>
<li><strong>Check Compatibility:</strong> Review your current codebase and installed plugins for compatibility with the new PHP version. Many developers provide updates or patches to ensure their software works with the latest PHP releases.</li>
<li><strong>Update Your Development Environment:</strong> Test the new PHP version on a local or staging environment. This allows you to identify and resolve any issues without affecting your live site.</li>
<li><strong>Update PHP Configuration:</strong> After upgrading, review and update your php.ini configuration file to ensure optimal performance and compatibility with the new version.</li>
<li><strong>Monitor Your Site:</strong> After the upgrade, closely monitor your website for any errors or performance issues, and address them promptly.</li>
</ul>
<h2>Best Practices for PHP Version Management</h2>
<p>Managing PHP versions effectively is key to maintaining a secure and efficient web environment. Here are some best practices to consider:</p>
<ul>
<li><strong>Regular Updates:</strong> Make it a routine to check for and apply PHP updates. Staying up-to-date reduces vulnerabilities and improves performance.</li>
<li><strong>Use Version Control:</strong> Implement version control systems like Git to manage code changes. This practice helps in tracking modifications and rolling back if necessary.</li>
<li><strong>Leverage Automation:</strong> Use automation tools for testing and deployment. Continuous integration/continuous deployment (CI/CD) pipelines can streamline the upgrade process, ensuring consistency and reducing human error.</li>
<li><strong>Documentation:</strong> Keep detailed records of your PHP version upgrades, including any changes made to configurations and the impact on your applications.</li>
</ul>
<h2>Common Issues and Troubleshooting PHP Upgrades</h2>
<p>PHP upgrades can sometimes lead to unexpected issues. Here’s how to troubleshoot common problems:</p>
<ul>
<li><strong>Compatibility Errors:</strong> If your website breaks after an upgrade, check for deprecated functions or incompatible plugins. Update or replace them with compatible alternatives.</li>
<li><strong>Performance Issues:</strong> If you notice a slowdown, review your PHP configurations and optimize settings such as memory limits and execution times.</li>
<li><strong>Debugging:</strong> Enable error reporting in your PHP settings to identify and fix issues. Use tools like Xdebug for more in-depth debugging.</li>
<li><strong>Log Analysis:</strong> Regularly check server logs for errors or warnings that can provide insight into what might be causing issues post-upgrade.</li>
</ul>
<h2>Comparing PHP Versions: Features and Improvements</h2>
<p>Each PHP version brings new features and improvements. Here&#8217;s a comparison of recent PHP versions to help you understand the benefits of upgrading:</p>
<table>
<thead>
<tr>
<th>PHP Version</th>
<th>Key Features</th>
<th>Performance Improvements</th>
</tr>
</thead>
<tbody>
<tr>
<td>PHP 7.4</td>
<td>Arrow functions, typed properties, preloading</td>
<td>Significant performance boost over PHP 7.3</td>
</tr>
<tr>
<td>PHP 8.0</td>
<td>JIT compilation, union types, named arguments</td>
<td>Further performance enhancements with JIT</td>
</tr>
<tr>
<td>PHP 8.1</td>
<td>Enums, fibers, read-only properties</td>
<td>Improved performance and memory usage</td>
</tr>
</tbody>
</table>
<h2>Understanding PHP Version Compatibility with Hosting Environments</h2>
<p>Upgrading your PHP version is crucial, but it&#8217;s equally important to ensure compatibility with your hosting environment. Different hosting providers offer varying levels of support for PHP versions. Before initiating an upgrade, check if your hosting provider supports the latest PHP version and any associated extensions you might need.</p>
<p>Shared hosting environments often lag in supporting the newest PHP versions due to the need to maintain stability across numerous accounts. If you&#8217;re using a VPS or dedicated server, you might have more flexibility and control over the PHP version you can install. Always consult your hosting provider&#8217;s documentation or support team to confirm compatibility and to understand any potential limitations.</p>
<p>Additionally, consider the compatibility of your web applications and CMS platforms. Some platforms may not yet fully support the latest PHP versions, which could lead to functionality issues. Testing the upgrade in a staging environment before deploying it live is a best practice that can prevent unexpected disruptions.</p>
<h2>Best Practices for Testing PHP Version Upgrades</h2>
<p>Testing is a critical step in the PHP upgrade process to ensure that your applications continue to function correctly. Begin by setting up a staging environment that mirrors your production setup. This allows you to test the PHP upgrade without affecting your live site.</p>
<p>In the staging environment, run a comprehensive set of tests to cover all functionalities of your application. This includes unit tests, integration tests, and manual testing of key user workflows. Pay special attention to any custom scripts or plugins, as these are often the source of compatibility issues.</p>
<ul>
<li><strong>Unit Testing:</strong> Use tools like PHPUnit to test individual components of your application for compatibility with the new PHP version.</li>
<li><strong>Integration Testing:</strong> Ensure that all parts of your application work together seamlessly under the new PHP version.</li>
<li><strong>Manual Testing:</strong> Simulate user actions to check for any unexpected behavior or errors.</li>
</ul>
<p>Document any issues encountered during testing and address them before proceeding with the upgrade on your live site. This proactive approach minimizes downtime and ensures a smooth transition.</p>
<h2>Troubleshooting Common Issues After a PHP Upgrade</h2>
<p>Even with thorough preparation, issues can arise after upgrading your PHP version. Common problems include deprecated functions, compatibility errors with third-party plugins, and performance issues. Identifying and resolving these issues promptly is essential for maintaining site stability.</p>
<p>Start by enabling error reporting in your PHP configuration to capture any error messages. This can provide valuable insights into what might be going wrong. Look for deprecated functions in your codebase, as newer PHP versions often deprecate older functions. Updating or replacing these functions with their modern equivalents is necessary for compatibility.</p>
<p>If you encounter plugin compatibility issues, check for updates from the plugin developers. Many developers release updates to ensure compatibility with the latest PHP versions. If no updates are available, consider reaching out to the developer for support or looking for alternative plugins.</p>
<p>Performance issues can sometimes occur due to changes in PHP&#8217;s internal handling of resources. Profiling your application with tools like Xdebug or New Relic can help identify bottlenecks introduced by the upgrade. Optimizing your code and server configuration based on these findings can restore and even enhance performance.</p>
<h2>Comparing PHP Versions: Performance and Security Improvements</h2>
<p>Each new PHP version comes with performance enhancements and security improvements that can significantly benefit your application. Comparing the differences between versions can help you understand the tangible benefits of upgrading.</p>
<table>
<thead>
<tr>
<th>PHP Version</th>
<th>Performance Improvement</th>
<th>Security Enhancements</th>
</tr>
</thead>
<tbody>
<tr>
<td>PHP 7.4</td>
<td>20-30% faster execution compared to PHP 7.3</td>
<td>Typed properties, improved type checks</td>
</tr>
<tr>
<td>PHP 8.0</td>
<td>JIT compiler for significant performance boosts</td>
<td>Improved error handling, new cryptographic functions</td>
</tr>
<tr>
<td>PHP 8.1</td>
<td>Further JIT optimizations, asynchronous signal handling</td>
<td>Fibers for improved concurrency, read-only properties</td>
</tr>
</tbody>
</table>
<p>Upgrading to a newer PHP version can lead to faster page loads and reduced resource consumption, directly impacting user experience and server costs. Additionally, security enhancements protect your application from vulnerabilities, making regular upgrades a critical component of your security strategy.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://rackset.com/learn/server/why-you-need-to-upgrade-your-php-to-latest-version/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What’s New in PHP 8.2 &#8211;  Changes and Updates</title>
		<link>https://rackset.com/learn/server/whats-new-in-php-8-2-changes-and-updates</link>
					<comments>https://rackset.com/learn/server/whats-new-in-php-8-2-changes-and-updates#respond</comments>
		
		<dc:creator><![CDATA[rackset]]></dc:creator>
		<pubDate>Wed, 28 Dec 2022 15:08:22 +0000</pubDate>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Server Management & Monitoring]]></category>
		<category><![CDATA[buy VPS server with php 8.2]]></category>
		<category><![CDATA[Is php 8.2 released]]></category>
		<category><![CDATA[php 8.2 changes]]></category>
		<category><![CDATA[php 8.2 new features]]></category>
		<category><![CDATA[php 8.2 performance]]></category>
		<category><![CDATA[php 8.2 release date]]></category>
		<category><![CDATA[php latest version]]></category>
		<guid isPermaLink="false">https://rackset.com/?post_type=blog&#038;p=6896</guid>

					<description><![CDATA[PHP 8.2 is built on the new base laid out in PHP 8.0 in addition to PHP 8.1. With PHP 8.2 release date being released, we&#8217;ll look at the PHP 8.2 changes in detail, from the enhancements and new features to minor and deprecations, we&#8217;ll review everything. Since PHP 8.2 entered its feature freeze on [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>PHP 8.2 is built on the new base laid out in PHP 8.0 in addition to PHP 8.1. With <strong>PHP 8.2 release date</strong> being released, we&#8217;ll look at the <strong>PHP 8.2 changes</strong> in detail, from the enhancements and new features to minor and deprecations, we&#8217;ll review everything.</p>
<p>Since PHP 8.2 entered its feature freeze on the 19th of July 2022, we can anticipate nothing new to add to this list.</p>
<p>&nbsp;</p>
<h2>New Features and Improvements in PHP 8.2</h2>
<p>With <strong>PHP latest version</strong>, a lot of hosting companies offer the latest version once you buy a VPS hosting account to take your website to the next version with <strong>PHP 8.2 new features</strong>. But what is added in the <strong>PHP latest version</strong>?</p>
<p>&nbsp;</p>
<h3>Readonly Classes</h3>
<p>Readonly properties were added within an account once you <a href="https://rackset.com/server/vps-server/" target="_blank" rel="noopener"><strong>buy VPS server with PHP 8.2</strong></a> or you can update your current version. This RFC builds upon them and includes syntactic sugar, making all class properties read-only all at once. Instead of writing:</p>
<p>class Post</p>
<p>{</p>
<p>public function __construct(</p>
<p>public readonly string $title,</p>
<p>public readonly Author $author,</p>
<p>public readonly string $body,</p>
<p>public readonly DateTime $publishedAt,</p>
<p>) {}</p>
<p>}</p>
<p>Now you can write:</p>
<p>readonly class Post</p>
<p>{</p>
<p>public function __construct(</p>
<p>public string $title,</p>
<p>public Author $author,</p>
<p>public string $body,</p>
<p>public DateTime $publishedAt,</p>
<p>) {}</p>
<p>}</p>
<p>&nbsp;</p>
<p>Functionally creating a class as read-only is exactly similar to making each property read-only. However, it also blocks dynamic properties from being added to the class:</p>
<p>$post = new Post(<i>/* … */</i>);</p>
<p>&nbsp;</p>
<p>$post-&gt;unknown = &#8216;wrong&#8217;;</p>
<p>&nbsp;</p>
<p>It is important to note that you are able to extend the read-only class if the child class is read-only also.</p>
<p>&nbsp;</p>
<h3>Deprecate dynamic properties</h3>
<p>We’d consider this to be an improvement to the <strong>PHP 8.2 changes</strong>; however, it may be a bit painful. Dynamic properties will be removed in <strong>PHP 8.2</strong> and will generate an ErrorException in PHP 9.0:</p>
<p>class Post</p>
<p>{</p>
<p>public string $title;</p>
<p>}</p>
<p>&nbsp;</p>
<p><i>// …</i></p>
<p>&nbsp;</p>
<p>$post-&gt;name = &#8216;Name&#8217;;</p>
<p>Remember that classes that implement __get and __set will continue to function according to the intended way:</p>
<p>class Post</p>
<p>{</p>
<p>private array $properties = [];</p>
<p>public function __set(string $name, mixed $value): void</p>
<p>{</p>
<p>$this-&gt;properties[$name] = $value;</p>
<p>}</p>
<p>}</p>
<p>&nbsp;</p>
<p><i>// …</i></p>
<p>&nbsp;</p>
<p>$post-&gt;name = &#8216;Name&#8217;;</p>
<p>&nbsp;</p>
<h3>New Random Extension</h3>
<p>PHP 8.2 includes a brand new random number generator, which fixes many of the issues with the old one, makes it more efficient and secure, simpler to maintain and doesn&#8217;t depend on the global state, thereby eliminating many difficult-to-find bugs when making use of <strong>PHP 8.2 performance</strong> of random function.</p>
<p>There&#8217;s a brand new class called Randomizer that accepts an engine for randomization. You can now alter that engine to suit the requirements of your business. For instance, you can distinguish between a test and a production environment.</p>
<p>$rng = $is_production</p>
<p>? new RandomEngineSecure()</p>
<p>: new RandomEngineMt19937(1234);</p>
<p>&nbsp;</p>
<p>$randomizer = new RandomRandomizer($rng);</p>
<p>$randomizer-&gt;shuffleString(&#8216;foobar&#8217;);</p>
<p>&nbsp;</p>
<h3>false, true, or null false as stand-alone types</h3>
<p>With the <strong>PHP 8.2 released date</strong> it introduces three new types or something similar to it. We&#8217;ll stay clear of the rabbit hole of type security in this blog. However, technically true, false, and null can be considered valid types in their own right. The most common examples are PHP&#8217;s built-in function, in which false is the return type in the event that errors occur. For instance, in file_get_contents:</p>
<p>file_get_contents(<i>/* … */</i>): string|false</p>
<p>&nbsp;</p>
<p>Prior to PHP 8.2, it was possible to previously use false in conjunction with other types to form the union type; however, it is possible to use it as a stand-alone type, too:</p>
<p>function alwaysFalse(): false</p>
<p>{</p>
<p>return false;</p>
<p>}</p>
<p>&nbsp;</p>
<p>This is also true in the case of null and true.</p>
<p>&nbsp;</p>
<h3>Disjunctive Normal Form Types</h3>
<p>DNF types let us combine intersection types and union types. They follow an unwritten rule for combining intersection and union kinds; the intersection type has to be separated by brackets. In reality, it appears like this:</p>
<p>function generateSlug((HasTitle&amp;HasId)|null $post)</p>
<p>{</p>
<p>if ($post === null) {</p>
<p>return &#8221;;</p>
<p>}</p>
<p>&nbsp;</p>
<p>return</p>
<p>strtolower($post-&gt;getTitle())</p>
<p>. $post-&gt;getId();</p>
<p>}</p>
<p>In this case, (HasTitle&amp;HasId)|null is the DNF type.</p>
<p>This is a wonderful <strong>PHP 8.2 performance</strong> enhancement, particularly because it means we now use nullable intersection types. This is perhaps the most significant use case of this new feature.</p>
<p>&nbsp;</p>
<h3>Constants in the traits</h3>
<p>It is now possible to use constants in the following traits:</p>
<p>trait Foo</p>
<p>{</p>
<p>public const CONSTANT = 1;</p>
<p>&nbsp;</p>
<p>public function bar(): int</p>
<p>{</p>
<p>return self::CONSTANT;</p>
<p>}</p>
<p>}</p>
<p>It isn&#8217;t possible to access the constant through the trait&#8217;s name within the trait or inside it.</p>
<p>trait Foo</p>
<p>{</p>
<p>public const CONSTANT = 1;</p>
<p>&nbsp;</p>
<p>public function bar(): int</p>
<p>{</p>
<p>return Foo::CONSTANT;</p>
<p>}</p>
<p>}</p>
<p>&nbsp;</p>
<p>Foo::CONSTANT;</p>
<p>&nbsp;</p>
<p>You are able to access the constant through the class that utilizes the trait, provided that it&#8217;s publicly available:</p>
<p>class MyClass</p>
<p>{</p>
<p>use Foo;</p>
<p>}</p>
<p>&nbsp;</p>
<p>MyClass::CONSTANT; <i>// 1</i></p>
<h3></h3>
<h3>Redact Parameters from Back Tracks</h3>
<p>The most common practice in any codebase is to report mistakes in production to a system that keeps track of the errors and informs developers when something is wrong. This is usually done by sending stack trace data via wire to a third-party service. However, there are instances where these stack trace tracks can contain sensitive data such as passwords, environment variables, or usernames.</p>
<p><strong>PHP 8.2</strong> lets you identify these &#8220;sensitive parameters&#8221; with an attribute so that you don&#8217;t have to be concerned about them appearing in your stack trace when there&#8217;s a problem. Here&#8217;s an example from RFC:</p>
<p>function login(</p>
<p>string $user,</p>
<p>#[SensitiveParameter] string $password</p>
<p>) {</p>
<p><i>// …</i></p>
<p>throw new Exception(&#8216;Error&#8217;);</p>
<p>}</p>
<p>&nbsp;</p>
<p>login(&#8216;root&#8217;, &#8216;root&#8217;);</p>
<p>&nbsp;</p>
<h3>Fetch Properties for Enums within Const expressions</h3>
<p>This RFC proposes using the -&gt;or the? to retrieve properties of enums within constant expressions. The principal reason behind the change would be to permit the fetching of names and values of enums in locations where enum objects can&#8217;t be allowed, for example, array keys</p>
<p>This signifies that the following code is valid now:</p>
<p>enum A: string</p>
<p>{</p>
<p>case B = &#8216;B&#8217;;</p>
<p>const C = [self::B-&gt;value =&gt; self::B];</p>
<p>}</p>
<h3></h3>
<h3>Return type changes for DateTime::createFromImmutable() and DateTimeImmutable::createFromMutable() breaking</h3>
<p>The methods used in the past were as follows:</p>
<p>DateTime::createFromImmutable(): DateTime</p>
<p>DateTimeImmutable::createFromMutable(): DateTimeImmutable</p>
<p>In <strong>PHP 8.2</strong>, these method signatures have been changed the following:</p>
<p>DateTime::createFromImmutable(): static</p>
<p>DateTimeImmutable::createFromMutable(): static</p>
<p>&nbsp;</p>
<p>This change makes more sense as it enhances the static insight options for classes that extend beyond DateTime as well as DateTimeImmutable. However, technically speaking, this is a break-in that could impact the custom implementations that are derived from one of the two classes.</p>
<p>&nbsp;</p>
<h3>Utf8_encode () and the utf8_decode () deprecations</h3>
<p>In PHP 8.2 in PHP 8.2, using either the utf8_encode () or utf8_decode (), will cause these notices of deprecation:</p>
<p>Deprecated: Function utf8_encode() is deprecated</p>
<p>Deprecated: Function utf8_decode() is deprecated</p>
<p>The RFC claims that these functions are given a misleading name that can lead to confusion. They only change to ISO-8859-1 and UTF-8 as well as the name suggests a more broad usage. The RFC provides a more thorough explanation regarding the logic behind the RFC.</p>
<p>What is the alternative? The RFC suggests using mb_convert_encoding() instead.</p>
<p>&nbsp;</p>
<h3>Strtolower that is locale insensitive () and strtoupper ()</h3>
<p>The strtolower () and strtoupper () are no longer localized. You can utilize strtolower mb_strtolower () if you&#8217;d like a locally-specific case converter.</p>
<p>&nbsp;</p>
<h3>Signature changes to various SPL methods</h3>
<p>The methods for SPL types have been modified to make sure they are properly enforced. Signature type:</p>
<p>SplFileInfo::_bad_state_ex()</p>
<p>SplFileObject::getCsvControl()</p>
<p>SplFileObject::fflush()</p>
<p>SplFileObject::ftell()</p>
<p>SplFileObject::fgetc()</p>
<p>SplFileObject::fpassthru()</p>
<p>SplFileObject::hasChildren()</p>
<p>SplFileObject::getChildren()</p>
<p>&nbsp;</p>
<h3>New N modifier for PCRE</h3>
<p>You are now able to utilize the N mod (NO_AUTO_CAPTURE) in Pcre* functions.</p>
<p>&nbsp;</p>
<h3>ODBC username and password</h3>
<p>It is now possible to use the ODBC extension to escape users&#8217; usernames and passwords in the scenario where both a connection string as well as username/password are provided, and the string needs to be added.</p>
<p>Similar to PDO_ODBC.</p>
<p>&nbsp;</p>
<h3>Deprecate ${} String Interpolation</h3>
<p>PHP offers a variety of ways of embedding variables within strings. This RFC disapproves of two ways of doing this because they aren&#8217;t used frequently and frequently cause confusion.</p>
<p>&#8220;Hello ${world}&#8221;;</p>
<p>Deprecated: Using ${} in strings is deprecated</p>
<p>&nbsp;</p>
<p>&#8220;Hello ${(world)}&#8221;;</p>
<p>Deprecated: Using ${} (variable variables) in strings is deprecated</p>
<p>To be precise: the two most well-known methods of interpolating strings still function:</p>
<p>&#8220;Hello {$world}&#8221;;</p>
<p>&#8220;Hello $world&#8221;;</p>
<p>&nbsp;</p>
<h3>Deprecate Supported Callables</h3>
<p>Another change, though with a smaller consequence, is the partially supported callables are now being discarded too. Partially supported callables are callables that can be called using call_user_func($callable) but not by calling $callable() directly. The list of these types of callables is quite brief, in fact:</p>
<p>&#8220;self::method&#8221;</p>
<p>&#8220;parent::method&#8221;</p>
<p>&#8220;static::method&#8221;</p>
<p>[&#8220;self&#8221;, &#8220;method&#8221;]</p>
<p>[&#8220;parent&#8221;, &#8220;method&#8221;]</p>
<p>[&#8220;static&#8221;, &#8220;method&#8221;]</p>
<p>[&#8220;Foo&#8221;, &#8220;Bar::method&#8221;]</p>
<p>[new Foo, &#8220;Bar::method&#8221;]</p>
<p>The motivation behind this? It&#8217;s an important move in the right direction toward having the ability to use calls properties that can be typed.</p>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p><strong>Is PHP 8.2 released?</strong> <span style="text-decoration: underline;">Yes</span>, with the <strong>PHP latest version</strong> there have been many new changes and <strong>PHP 8.2 new features</strong> added. You can either upgrade your current version or <a href="https://rackset.com/server/vps-server/" target="_blank" rel="noopener"><strong>buy VPS server with PHP 8.2 already installed</strong></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://rackset.com/learn/server/whats-new-in-php-8-2-changes-and-updates/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
