{"id":6942,"date":"2021-12-20T15:13:54","date_gmt":"2021-12-20T15:13:54","guid":{"rendered":"https:\/\/www.fastcomet.com\/blog\/?p=6942"},"modified":"2022-06-09T14:41:22","modified_gmt":"2022-06-09T14:41:22","slug":"php-8-1-available","status":"publish","type":"post","link":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available","title":{"rendered":"PHP 8.1 is Now Available at FastComet"},"content":{"rendered":"\n<p class=\"has-drop-cap\">Released for General Availability on November 25, 2021, PHP 8.1 is now fully available for all FastComet clients. We have performed our mandatory extensive testing and monitoring in order to ensure complete compatibility of the PHP 8.1 integration with cPanel and our infrastructure. We can state with confidence that it\u2019s safe to deploy the new PHP version that provides stability and optimal performance for your PHP applications.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>The new version of the programming language is packed with several exciting features. Those include pure intersection types, enums, fibers, new <code>readonly<\/code> properties, and many more.<\/p>\n\n\n\n<p>In this article, we\u2019ll cover what\u2019s new, changed, and deprecated in PHP 8.1\u2014from its new features and performance improvements to significant changes and deprecations.<\/p>\n\n\n\n<p><strong>Table of Contents:<\/strong><\/p>\n\n\n\n<ul class=\"nav-list wp-block-list\"><li><a href=\"#h-php-8-1-for-all-fastcomet-users\">PHP 8.1 for all FastComet Users<\/a><\/li><li><a href=\"#h-new-features-in-php-8-1\">New Features in PHP 8.1<\/a><ul><li><a href=\"#h-pure-intersection-types\">Pure Intersection Types<\/a><\/li><li><a href=\"#h-enums\">Enums<\/a><\/li><li><a href=\"#h-the-never-return-type\">The never Return Type<\/a><\/li><li><a href=\"#h-fibers\">Fibers<\/a><\/li><li><a href=\"#h-new-readonly-properties\">New readonly Properties<\/a><\/li><li><a href=\"#h-a-list-of-the-remaining-php-8-1-new-features-with-links\">A List of The Remaining PHP 8.1 New Features (with Links)<\/a><\/li><\/ul><\/li><li><a href=\"#h-changes-in-php-8-1\">Changes in PHP 8.1<\/a><ul><li><a href=\"#h-php-interactive-shell-requires-readline-extension\">PHP Interactive Shell Requires readline Extension<\/a><\/li><li><a href=\"#h-mysqli-default-error-mode-set-to-exceptions\">MySQLi Default Error Mode Set to Exceptions<\/a><\/li><li><a href=\"#h-customizable-line-endings-for-csv-writing-functions\">Customizable Line Endings for CSV Writing Functions<\/a><\/li><li><a href=\"#h-a-list-of-the-remaining-php-8-1-changes-with-links\">A List of The Remaining PHP 8.1 Changes (with Links)<\/a><\/li><\/ul><\/li><li><a href=\"#h-list-of-deprecations-in-php-8-1\">List of Deprecations in PHP 8.1<\/a><\/li><li><a href=\"#h-other-minor-changes\">Other Minor Changes<\/a><\/li><li><a href=\"#h-how-to-upgrade-to-php-8-1\">How to Upgrade to PHP 8.1<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"h3 wp-block-heading\" id=\"h-php-8-1-for-all-fastcomet-users\">PHP 8.1 for all FastComet Users<\/h2>\n\n\n\n<p>PHP 8.1 is now available on all FastComet shared servers and all clients can easily select it via the FastComet PHP Selector. PHP 8.1 is the fastest version of PHP yet, which is why we recommend upgrading if your site is fully compatible with it. However, keep note that some plugins may not be compatible with the new version. Don\u2019t forget to always check your website thoroughly after switching to a new PHP version.<\/p>\n\n\n\n<h2 class=\"h3 wp-block-heading\" id=\"h-new-features-in-php-8-1\">New Features in PHP 8.1<\/h2>\n\n\n\n<p>Let\u2019s start by covering the new features in PHP 8.1.<\/p>\n\n\n\n<h3 class=\"h4 wp-block-heading\" id=\"h-pure-intersection-types\">Pure Intersection Types<\/h3>\n\n\n\n<p>PHP 8.1 adds support for intersection types. It\u2019s similar to union types introduced in <a href=\"https:\/\/www.fastcomet.com\/blog\/php-8-0-available\" target=\"_blank\" rel=\"noreferrer noopener\">PHP 8.0<\/a>, but their intended usage is the exact opposite.<\/p>\n\n\n\n<p>To understand its usage better, let\u2019s refresh how type declarations work in PHP. Essentially, you can add type declarations to function arguments, return values, and class properties. This assignment is called type hinting and ensures that the value is of the correct type at call time. Otherwise, it throws up a <a href=\"https:\/\/www.php.net\/manual\/en\/class.typeerror.php\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">TypeError<\/a> right away. In turn, this helps you debug code better.<\/p>\n\n\n\n<p>However, declaring a single type has its limitations. Union types help you overcome that by allowing you to declare a value with multiple types, and the input has to satisfy at least one of the declared types.<\/p>\n\n\n\n<p>See how <a href=\"https:\/\/wiki.php.net\/rfc\/pure-intersection-types\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">the RFC describes pure intersection types<\/a> straight from the source.<\/p>\n\n\n\n<h3 class=\"h4 wp-block-heading\" id=\"h-enums\">Enums<\/h3>\n\n\n\n<p>PHP 8.1 is finally adding support for enums (also called enumerations or enumerated types). They\u2019re a user-defined data type consisting of a set of possible values. The most common enums example in programming languages is the boolean type, with true and false as two possible values. It\u2019s so common that it\u2019s baked into many modern programming languages.<\/p>\n\n\n\n<p>As per <a href=\"https:\/\/wiki.php.net\/rfc\/enumerations\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">the enumerations RFC<\/a>, enums in PHP will be restricted to \u201cunit enumerations\u201d at first.<\/p>\n\n\n\n<p>The RFC delves further into enum methods, static methods, constants, constant expressions, and much more. Covering them all is beyond the scope of this article. You can refer to the documentation to familiarize yourself with all its goodness.<\/p>\n\n\n\n<h3 class=\"h4 wp-block-heading\" id=\"h-the-never-return-type\">The Never Return Type<\/h3>\n\n\n\n<p>PHP 8.1 adds a new return type hint called never. It\u2019s super helpful to use in functions that always throw or exit.<\/p>\n\n\n\n<p>As per the RFC, URL redirect functions that always exit (explicitly or implicitly) are a good example for its use:<\/p>\n\n\n\n<pre>function redirect(string $uri): never {<br>&nbsp;&nbsp;&nbsp;&nbsp;header('Location: ' . $uri);<br>&nbsp;&nbsp;&nbsp;&nbsp;exit();<br>}<br>function redirectToLoginPage(): never {<br>&nbsp;&nbsp;&nbsp;&nbsp;redirect('\/login');<br>}<\/pre>\n\n\n\n<p>A never-declared function should satisfy three conditions:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>It shouldn\u2019t have the return statement defined explicitly.<\/li><li>It shouldn\u2019t have the return statement defined implicitly (e.g. if-else statements).<\/li><li>It must end its execution with an exit statement (explicitly or implicitly).<\/li><\/ul>\n\n\n\n<p>The URL redirection example above shows both explicit and implicit usage of the never return type.<\/p>\n\n\n\n<p>For further information on the never return type follow <a href=\"https:\/\/wiki.php.net\/rfc\/noreturn_type\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">the official source<\/a>.<\/p>\n\n\n\n<h3 class=\"h4 wp-block-heading\" id=\"h-fibers\">Fibers<\/h3>\n\n\n\n<p>Historically, PHP code has almost always been synchronous code. The code execution halts till the result is returned, even for I\/O operations. You can imagine why this process may make code execution slower.<\/p>\n\n\n\n<p>There are multiple third-party solutions to overcome this obstacle to allow developers to write PHP code asynchronously, especially for concurrent I\/O operations. Some popular examples include <a href=\"https:\/\/amphp.org\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">amphp<\/a>, <a href=\"https:\/\/reactphp.org\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">ReactPHP<\/a>, and <a href=\"https:\/\/guzzlephp.org\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Guzzle<\/a>.<\/p>\n\n\n\n<p>However, there\u2019s no standard way to handle such instances in PHP. Moreover, treating synchronous and asynchronous code in the same call stack <a href=\"https:\/\/journal.stuffwithstuff.com\/2015\/02\/01\/what-color-is-your-function\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">leads to other problems<\/a>.<\/p>\n\n\n\n<p>Fibers are PHP\u2019s way of handling parallelism via virtual threads (or <a href=\"https:\/\/en.wikipedia.org\/wiki\/Green_threads\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">green threads<\/a>). It seeks to eliminate the difference between synchronous and asynchronous code by allowing PHP functions to interrupt without affecting the entire call stack.<\/p>\n\n\n\n<p>Here\u2019s what <a href=\"https:\/\/wiki.php.net\/rfc\/fibers\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">the RFC<\/a> promises:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Adding support for Fibers to PHP.<\/li><li>Introducing a new Fiber class and the corresponding reflection class ReflectionFiber.<\/li><li>Adding exception classes FiberError and FiberExit to represent errors.<\/li><li>Fibers allow for transparent non-blocking I\/O implementations of existing interfaces (PSR-7, Doctrine ORM, etc.). That\u2019s because the placeholder (promise) object is eliminated. Instead, functions can declare the I\/O result type instead of a placeholder object that cannot specify a resolution type because PHP does not support generics.<\/li><\/ul>\n\n\n\n<h3 class=\"h4 wp-block-heading\" id=\"h-new-readonly-properties\">New <code>readonly<\/code> Properties<\/h3>\n\n\n\n<p>PHP 8.1 adds support for readonly properties. They can only be initialized once from the scope where they\u2019re declared. Once initialized, you cannot modify their value ever. Doing so would throw up an Error exception.<\/p>\n\n\n\n<p><a href=\"https:\/\/wiki.php.net\/rfc\/readonly_properties_v2\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Its RFC<\/a> reads:<\/p>\n\n\n\n<p>A readonly property can only be initialized once, and only from the scope where it has been declared. Any other assignment or modification of the property will result in an Error exception.<\/p>\n\n\n\n<p>Here\u2019s an example of how you can use it:<\/p>\n\n\n\n<pre>class Test {<br>&nbsp;&nbsp;&nbsp;&nbsp;public readonly string $example;<br>&nbsp;&nbsp;&nbsp;&nbsp;public function __construct(string $example) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Legal initialization.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;example = $example;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<\/pre>\n\n\n\n<p>Once initialized, there\u2019s no going back. Having this feature baked into PHP greatly reduces boilerplate code that\u2019s often used to enable this functionality.<\/p>\n\n\n\n<p>The <code>readonly<\/code> property offers a strong immutability guarantee, both inside and outside the class. It doesn\u2019t matter what code runs in between. Calling a <code>readonly<\/code> property will always return the same value.<\/p>\n\n\n\n<p>However, using the <code>readonly<\/code> property may not be ideal in specific use cases. For example, you can only use them alongside a typed property because declarations without a type are implicitly null and cannot be <code>readonly<\/code>.<\/p>\n\n\n\n<p>Furthermore, setting a <code>readonly<\/code> property does not make objects immutable. The <code>readonly<\/code> property will hold the same object, but that object itself can change.<\/p>\n\n\n\n<p>Another minor issue with this property is that you cannot clone it. There\u2019s already a <a href=\"https:\/\/stitcher.io\/blog\/cloning-readonly-properties-in-php-81\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">workaround for this particular use case<\/a>. Look into it if necessary.<\/p>\n\n\n\n<h3 class=\"h4 wp-block-heading\" id=\"h-a-list-of-the-remaining-php-8-1-new-features-with-links\">A List of The Remaining PHP 8.1 New Features (with Links)<\/h3>\n\n\n\n<p>Because of the nature of this article, we cannot possibly go in detail about all the new features. That\u2019s why we will give you a list of them with all the needed links to the official source:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/wiki.php.net\/rfc\/final_class_const\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Define final Class Constants<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/fsync_function\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">New fsync() and fdatasync() Functions<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/is_list\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">New array_is_list() Function<\/a><\/li><li><a href=\"https:\/\/github.com\/php\/php-src\/pull\/6868\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">New Sodium XChaCha20 Functions<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/intldatetimepatterngenerator\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">New IntlDatePatternGenerator Class<\/a><\/li><li><a href=\"https:\/\/github.com\/php\/php-src\/pull\/7026\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Support for AVIF Image Format<\/a><\/li><li><a href=\"https:\/\/www.php.net\/manual\/en\/reserved.variables.files.php\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">New $_FILES: full_path Key for Directory Uploads<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/array_unpacking_string_keys\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Array Unpacking Support for String-Keyed Arrays<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/explicit_octal_notation\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Explicit Octal Numeral Notation<\/a><\/li><li>MurmurHash3 and xxHash Hash Algorithms Support &#8211; <a href=\"https:\/\/github.com\/php\/php-src\/pull\/6059\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">MurmurHash3<\/a>, <a href=\"https:\/\/php.watch\/versions\/8.1\/xxHash\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">xxHash<\/a>, <a href=\"https:\/\/github.com\/php\/php-src\/pull\/6400\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Algorithm-specific $options<\/a>.<\/li><li><a href=\"https:\/\/github.com\/curl\/curl\/wiki\/DNS-over-HTTPS\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">DNS-over-HTTPS (DoH) Support<\/a><\/li><li><a href=\"https:\/\/github.com\/php\/php-src\/pull\/6456\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">File Uploads from Strings with CURLStringFile<\/a><\/li><li><a href=\"https:\/\/github.com\/php\/php-src\/pull\/6632\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">New MYSQLI_REFRESH_REPLICA Constant<\/a><\/li><li><a href=\"https:\/\/github.com\/php\/php-src\/commit\/4b79dba93202ed5640dff317046ce2fdd42e1d82\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Performance Improvements with Inheritance Cache<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/first_class_callable_syntax\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">First-Class Callable Syntax<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"h3 wp-block-heading\" id=\"h-changes-in-php-8-1\">Changes in PHP 8.1<\/h2>\n\n\n\n<p>PHP 8.1 also includes changes to its existing syntax and features. We\u2019ll go over some of them and list the rest in the same manner as with the new features.<\/p>\n\n\n\n<h3 class=\"h4 wp-block-heading\" id=\"h-php-interactive-shell-requires-readline-extension\">PHP Interactive Shell Requires <code>readline<\/code> Extension<\/h3>\n\n\n\n<p>PHP\u2019s <code>readline<\/code> extension enables interactive shell features such as navigation, autocompletion, editing, and more. While it\u2019s bundled with PHP, it\u2019s not enabled by default.<\/p>\n\n\n\n<p>You can access the PHP interactive shell using PHP CLI\u2019s -a command-line option:<\/p>\n\n\n\n<pre>php -a<br>Interactive shell<br>PHP &gt;<br>php &gt; echo \"Hello\";<br>Hello<br>php &gt; function test() {<br>php { echo \"Hello\";<br>php { }<br>php &gt; test();<br>Hello<\/pre>\n\n\n\n<p>Before PHP 8.1, you could open the interactive shell using PHP CLI even without the readline extension enabled. As expected, the shell\u2019s interactive features didn\u2019t work, rendering the -a option meaningless.<\/p>\n\n\n\n<p>In PHP 8.1 CLI, the interactive shell exits with an error message if you\u2019ve <a href=\"https:\/\/github.com\/php\/php-src\/commit\/959e5787bdf7c088a57dce5f4f7570abd7fe35f8\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">not enabled the readline extension<\/a>.<\/p>\n\n\n\n<pre>php -a<\/pre>\n\n\n\n<p>Interactive shell (-a) requires the <code>readline<\/code> extension.<\/p>\n\n\n\n<h3 class=\"h4 wp-block-heading\" id=\"h-mysqli-default-error-mode-set-to-exceptions\">MySQLi Default Error Mode Set to Exceptions<\/h3>\n\n\n\n<p>Before PHP 8.1, MySQLi defaulted to silent the errors. This behavior often led to code that didn\u2019t follow strict Error\/Exception handling. Developers had to implement their own explicit error handling functions.<\/p>\n\n\n\n<p>PHP 8.1 changes this behavior by setting MySQLi\u2019s default error reporting mode to throw an exception.<\/p>\n\n\n\n<pre>Fatal error: Uncaught mysqli_sql_exception: Connection refused in ...:...<\/pre>\n\n\n\n<p>As this is a breaking change, for PHP &lt;8.1 versions, you should explicitly set the error handling mode using the mysqli_report function before making the first MySQLi connection. Alternatively, you can do the same by selecting the error reporting value by instantiating a mysqli_driver instance.<\/p>\n\n\n\n<p><a href=\"https:\/\/wiki.php.net\/rfc\/mysqli_default_errmode\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">The RFC<\/a> follows a <a href=\"https:\/\/wiki.php.net\/rfc\/pdo_default_errmode\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">similar change introduced in PHP 8.0<\/a>.<\/p>\n\n\n\n<h3 class=\"h4 wp-block-heading\" id=\"h-customizable-line-endings-for-csv-writing-functions\">Customizable Line Endings for CSV Writing Functions<\/h3>\n\n\n\n<p>Before PHP 8.1, PHP\u2019s built-in CSV writing functions, fputcsv and SplFileObject::fputcsv, were hard-coded to add \\n (or the Line-Feed character) at the end of every line.<\/p>\n\n\n\n<p>PHP 8.1 adds support for a new parameter named eol to these functions. You can use it to pass a configurable end-of-line character.&nbsp; By default, it still uses the \\n character. So, you can continue using it in your existing code.<\/p>\n\n\n\n<p>Standard character escaping rules apply for using end-of-line characters. If you want to use \\r, \\n, or \\r\\n as EOL characters, you must enclose them in double-quotes.<\/p>\n\n\n\n<p>Here\u2019s <a href=\"https:\/\/github.com\/php\/php-src\/pull\/6403\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">the GitHub page<\/a> tracking this new change.<\/p>\n\n\n\n<h3 class=\"h4 wp-block-heading\" id=\"h-a-list-of-the-remaining-php-8-1-changes-with-links\">A List of The Remaining PHP 8.1 Changes (with Links)<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/php.watch\/versions\/8.1\/version_compare-operator-restrictions\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">New version_compare Operator Restrictions<\/a><\/li><li><a href=\"https:\/\/www.php.net\/manual\/en\/function.htmlspecialchars.php\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">HTML Encoding and Decoding Functions Now Use ENT_QUOTES | ENT_SUBSTITUTE<\/a><\/li><li><a href=\"https:\/\/github.com\/php\/php-src\/pull\/6632\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Warning on Illegal compact Function Calls<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"h3 wp-block-heading\" id=\"h-list-of-deprecations-in-php-8-1\">List of Deprecations in PHP 8.1<\/h2>\n\n\n\n<p>PHP 8.1 deprecates many of its previous features. The following list provides a brief overview of the functionalities PHP 8.1 deprecates:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/wiki.php.net\/rfc\/deprecate_null_to_scalar_internal_arg\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Can\u2019t Pass null to Non-Nullable Internal Function Parameters<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/restrict_globals_usage\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Restricted $GLOBALS Usage<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/internal_method_return_types\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Return Type Declarations for Internal Functions<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/phase_out_serializable\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Serializable Interface Deprecated<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/implicit-float-int-deprecate\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Non-Compatible float to int Conversions Deprecated<\/a><\/li><li><a href=\"https:\/\/github.com\/php\/php-src\/pull\/6777\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">The mysqli::get_client_info Method and mysqli_get_client_info($param) Deprecated<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/deprecations_php_8_1#mhash_function_family\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">All mhash*() Functions (hash Extension) Are Deprecated<\/a><\/li><li><a href=\"https:\/\/wiki.php.net\/rfc\/autovivification_false\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Deprecate autovivification on false<\/a><\/li><li><a href=\"https:\/\/github.com\/php\/php-src\/commit\/3dfd3558ca2f63f\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">The mysqli_driver-&gt;driver_version Property Is Deprecated<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"h3 wp-block-heading\" id=\"h-other-minor-changes\">Other Minor Changes<\/h2>\n\n\n\n<p>There are <a href=\"https:\/\/wiki.php.net\/rfc\/deprecations_php_8_1\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">many more deprecations in PHP 8.1<\/a>. Listing them all here will be an exhausting exercise. We recommend you directly check the RFC for these minor deprecations. PHP\u2019s GitHub page also includes a <a href=\"https:\/\/github.com\/php\/php-src\/blob\/master\/UPGRADING\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">PHP 8.1 Upgrade Notes<\/a> guide. It lists all the breaking changes you should consider before upgrading to PHP 8.1.<\/p>\n\n\n\n<h2 class=\"h3 wp-block-heading\" id=\"h-how-to-upgrade-to-php-8-1\">How to Upgrade to PHP 8.1<\/h2>\n\n\n\n<p>With FastComet\u2019s shared hosting servers, you have the convenient option to <a href=\"https:\/\/www.fastcomet.com\/tutorials\/cpanel\/php-version\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">select your PHP version<\/a> quickly and easily. All you have to do is:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Go to your to <a href=\"https:\/\/my.fastcomet.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Client Area<\/a> \u2192 cPanel \u2192 Select PHP Version:<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"476\" src=\"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2020\/01\/find-php-selector-in-cpanel.jpg\" alt=\"Find PHP Selector in cPanel\" class=\"wp-image-4944\" srcset=\"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2020\/01\/find-php-selector-in-cpanel.jpg 1024w, https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2020\/01\/find-php-selector-in-cpanel-300x139.jpg 300w, https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2020\/01\/find-php-selector-in-cpanel-768x357.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>In the PHP Selector, click on the drop-down:<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/cpanel-php-81-switch.png\" alt=\"Choose PHP 8.1 from the Drop-down\" class=\"wp-image-6951\" srcset=\"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/cpanel-php-81-switch.png 1024w, https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/cpanel-php-81-switch-300x200.png 300w, https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/cpanel-php-81-switch-768x512.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Then, click on Set as Current:<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"326\" src=\"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/set-php-81-as-current.png\" alt=\"Set PHP 8.1 as Current\" class=\"wp-image-6952\" srcset=\"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/set-php-81-as-current.png 1024w, https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/set-php-81-as-current-300x96.png 300w, https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/set-php-81-as-current-768x245.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Done!<\/li><\/ul>\n\n\n\n<p>When switching between different PHP versions, remember to check your project compatibility before beginning the transition.<\/p>\n\n\n\n<h2 class=\"h3 wp-block-heading\" id=\"h-final-thoughts\">Final Thoughts<\/h2>\n\n\n\n<p>Once again, we\u2019ve covered all the key changes and improvements for the most recent PHP version\u20148.1. There are many changes this time around and we can&#8217;t wait to see what will come with the programming language&#8217;s new version.<\/p>\n\n\n\n<p>Use the comment section to share with us which PHP 8.1 changes and improvements you like the most, or perhaps what you dislike. Happy Coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Released for General Availability on November 25, 2021, PHP 8.1 is now fully available for all FastComet clients. We have performed our mandatory extensive testing and monitoring in order to ensure complete compatibility of the PHP 8.1 integration with cPanel and our infrastructure. We can state with confidence that it\u2019s safe to deploy the new [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":6957,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4726],"tags":[4676,103,4675],"class_list":["post-6942","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-service-updates","tag-news","tag-php","tag-php-8-1"],"featured_image_src":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/PHP-8.1-What-s-New.png","author_info":{"display_name":"Joseph","author_link":"https:\/\/www.fastcomet.com\/blog\/author\/joseph"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PHP 8.1 is Now Available at FastComet | FastComet<\/title>\n<meta name=\"description\" content=\"PHP 8.1 has been deployed on all FastComet servers. Follow our article for thorough info about PHP&#039;s new features, changes, and deprecations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.fastcomet.com\/blog\/php-8-1-available\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP 8.1 is Now Available at FastComet | FastComet\" \/>\n<meta property=\"og:description\" content=\"PHP 8.1 has been deployed on all FastComet servers. Follow our article for thorough info about PHP&#039;s new features, changes, and deprecations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fastcomet.com\/blog\/php-8-1-available\" \/>\n<meta property=\"og:site_name\" content=\"FastComet Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-20T15:13:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-09T14:41:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/PHP-8.1-What-s-New.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"620\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Joseph\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joseph\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP 8.1 is Now Available at FastComet | FastComet","description":"PHP 8.1 has been deployed on all FastComet servers. Follow our article for thorough info about PHP's new features, changes, and deprecations.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available","og_locale":"en_US","og_type":"article","og_title":"PHP 8.1 is Now Available at FastComet | FastComet","og_description":"PHP 8.1 has been deployed on all FastComet servers. Follow our article for thorough info about PHP's new features, changes, and deprecations.","og_url":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available","og_site_name":"FastComet Blog","article_published_time":"2021-12-20T15:13:54+00:00","article_modified_time":"2022-06-09T14:41:22+00:00","og_image":[{"width":1024,"height":620,"url":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/PHP-8.1-What-s-New.png","type":"image\/png"}],"author":"Joseph","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Joseph","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available#article","isPartOf":{"@id":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available"},"author":{"name":"Joseph","@id":"https:\/\/www.fastcomet.com\/blog\/#\/schema\/person\/4f2c9600f49c872b8d56996ee3b95035"},"headline":"PHP 8.1 is Now Available at FastComet","datePublished":"2021-12-20T15:13:54+00:00","dateModified":"2022-06-09T14:41:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available"},"wordCount":1882,"commentCount":0,"image":{"@id":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available#primaryimage"},"thumbnailUrl":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/PHP-8.1-What-s-New.png","keywords":["news","php","php 8.1"],"articleSection":["Service Updates"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.fastcomet.com\/blog\/php-8-1-available#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available","url":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available","name":"PHP 8.1 is Now Available at FastComet | FastComet","isPartOf":{"@id":"https:\/\/www.fastcomet.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available#primaryimage"},"image":{"@id":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available#primaryimage"},"thumbnailUrl":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/PHP-8.1-What-s-New.png","datePublished":"2021-12-20T15:13:54+00:00","dateModified":"2022-06-09T14:41:22+00:00","author":{"@id":"https:\/\/www.fastcomet.com\/blog\/#\/schema\/person\/4f2c9600f49c872b8d56996ee3b95035"},"description":"PHP 8.1 has been deployed on all FastComet servers. Follow our article for thorough info about PHP's new features, changes, and deprecations.","breadcrumb":{"@id":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fastcomet.com\/blog\/php-8-1-available"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available#primaryimage","url":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/PHP-8.1-What-s-New.png","contentUrl":"https:\/\/www.fastcomet.com\/blog\/wp-content\/uploads\/2021\/12\/PHP-8.1-What-s-New.png","width":1024,"height":620,"caption":"PHP 8.1 Available at FastComet"},{"@type":"BreadcrumbList","@id":"https:\/\/www.fastcomet.com\/blog\/php-8-1-available#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fastcomet.com\/blog"},{"@type":"ListItem","position":2,"name":"PHP 8.1 is Now Available at FastComet"}]},{"@type":"WebSite","@id":"https:\/\/www.fastcomet.com\/blog\/#website","url":"https:\/\/www.fastcomet.com\/blog\/","name":"FastComet Blog","description":"FastComet Web Hosting Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.fastcomet.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.fastcomet.com\/blog\/#\/schema\/person\/4f2c9600f49c872b8d56996ee3b95035","name":"Joseph","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fastcomet.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1aa84dc2a6398ed73c957bd1de58806d12d44e2956744ed1ae9b435d57822ab7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1aa84dc2a6398ed73c957bd1de58806d12d44e2956744ed1ae9b435d57822ab7?s=96&d=mm&r=g","caption":"Joseph"},"description":"Joseph is part of the FastComet Marketing team. With years of content writing experience behind him, it's one of his favorite activities. Joseph takes part in the SEO of the FastComet website and blog. His goal is to write comprehensive posts and guides, always aiming to help our clients with essential information. Joseph also has a thirst for knowledge and improvement, which makes the hosting environment a perfect place for him.","sameAs":["https:\/\/www.fastcomet.com\/"],"url":"https:\/\/www.fastcomet.com\/blog\/author\/joseph"}]}},"_links":{"self":[{"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/posts\/6942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/comments?post=6942"}],"version-history":[{"count":11,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/posts\/6942\/revisions"}],"predecessor-version":[{"id":10960,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/posts\/6942\/revisions\/10960"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/media\/6957"}],"wp:attachment":[{"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/media?parent=6942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/categories?post=6942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fastcomet.com\/blog\/wp-json\/wp\/v2\/tags?post=6942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}