{"id":20957,"date":"2026-11-26T10:10:07","date_gmt":"2026-11-26T10:10:07","guid":{"rendered":"https:\/\/www.20i.com\/blog\/?p=20957"},"modified":"2026-11-26T10:10:08","modified_gmt":"2026-11-26T10:10:08","slug":"php-8-6","status":"publish","type":"post","link":"https:\/\/www.20i.com\/blog\/php-8-6\/","title":{"rendered":"PHP 8.6 is here and ready to use on 20i"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">PHP 8.6 is available on 20i hosting. You can switch your sites over today from My20i, in just a few clicks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is a big release. It brings cleaner syntax, stronger types and better tools for high-traffic apps. Here&#8217;s what&#8217;s new, what&#8217;s changed and what to check before you upgrade.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The headline features<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Partial Function Application<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can now fill in some of a function&#8217;s arguments up front and get back a Closure that takes the rest. Use <code>?<\/code> for a single missing argument and <code>...<\/code> for the remainder. It means fewer throwaway arrow functions in your code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ PHP 8.5\n$supported = array_filter($versions, fn ($v) =&gt; version_compare($v, '8.6', '&gt;='));\n\n\/\/ PHP 8.6\n$supported = array_filter($versions, version_compare(?, '8.6', '&gt;='));<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">A new Duration class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>\\Time\\Duration<\/code> represents elapsed time, like a stopwatch reading. It has nanosecond precision, covers more than 250 years and doesn&#8217;t care about timezones. That makes timeouts, retries and benchmarks far easier to read than raw microsecond integers.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>use Time\\Duration;\n\n$timeout = Duration::fromSeconds(30);\n$retryAfter = Duration::fromMilliseconds(250);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">The Polling API<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The new <code>Io\\Poll<\/code> API watches lots of streams at once using the best method each platform offers (epoll, kqueue, event ports or WSAPoll). It removes the 1,024 connection ceiling that often limits <code>stream_select()<\/code>. Event loop libraries such as ReactPHP and AMPHP can now build on one shared, native foundation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">clamp()<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A small one that you&#8217;ll use all the time. <code>clamp()<\/code> keeps a value inside a range and returns the nearest boundary if it falls outside.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>clamp(110, 0, 100); \/\/ 100\nclamp(-10, 0, 100); \/\/ 0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It works with any comparable value, including the new Duration class.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SortDirection enum<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>SortDirection::Ascending<\/code> and <code>SortDirection::Descending<\/code> give every library one standard, type-safe way to express sort order. No more mixing integers, strings and booleans across packages. Pass the wrong thing and you get a clear TypeError rather than a confusing failure deep inside a method.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Readonly property defaults<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Readonly properties can now declare a default value directly. Fixed values no longer need assigning in the constructor, so classes get shorter and easier to scan.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Structured stream errors<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Stream operations can now throw a <code>StreamException<\/code> or fail quietly instead of emitting warnings. Each error comes with a <code>StreamErrorCode<\/code> enum, the wrapper name and the affected path or URL. That&#8217;s a big step up from parsing the message string out of <code>error_get_last()<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Better tools for developers<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Function and method parameters can have their own DocComments, readable through <code>ReflectionParameter::getDocComment()<\/code><\/li>\n\n\n\n<li>New <code>ReflectionProperty::isReadable()<\/code> and <code>isWritable()<\/code> methods tell you whether a property can actually be read or written, taking readonly, asymmetric visibility and hooks into account<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Performance improvements<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PHP 8.6 includes several under-the-hood speed-ups:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>array_map()<\/code> calls using first-class callables or partial application now compile into plain loops<\/li>\n\n\n\n<li>Faster <code>printf()<\/code> calls and faster JSON encoding<\/li>\n\n\n\n<li>Stateless closures are cached<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Other improvements worth knowing<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Security:<\/strong> the Sodium extension adds post-quantum key encapsulation (X-Wing and ML-KEM-768), IP address encryption and SHAKE\/TurboSHAKE functions<\/li>\n\n\n\n<li><strong>TLS:<\/strong> streams now support session resumption, external pre-shared keys and TLS 1.3 early data (0-RTT)<\/li>\n\n\n\n<li><strong>URIs:<\/strong> new builder classes for RFC 3986 URIs and WHATWG URLs, plus host and URI type detection<\/li>\n\n\n\n<li><strong>MySQL:<\/strong> a new <code>mysqli::quote_string()<\/code> method escapes and quotes a string, matching <code>PDO::quote()<\/code><\/li>\n\n\n\n<li><strong>Debugging:<\/strong> JSON error messages now point to where the error is in the input<\/li>\n\n\n\n<li><strong>Archives:<\/strong> <code>ZipArchive::openString()<\/code> and <code>closeString()<\/code> work with zip files held in memory<\/li>\n\n\n\n<li><strong>Enums and attributes:<\/strong> <code>#[\\Override]<\/code> now works on class constants and enum cases, and enums can implement <code>__debugInfo()<\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Check these before you upgrade<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most of the changes below are deprecations. Your code will still run, but you&#8217;ll see notices and these features will be removed in a future version. A few are genuine behaviour changes, so they&#8217;re worth a look.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Deprecations to look out for:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>return<\/code> inside a <code>finally<\/code> block, because it silently swallows exceptions<\/li>\n\n\n\n<li>Returning a value from <code>__construct()<\/code> or <code>__destruct()<\/code><\/li>\n\n\n\n<li>The mbstring regex functions such as <code>mb_ereg()<\/code> and <code>mb_split()<\/code> (use PCRE with the <code>u<\/code> modifier instead)<\/li>\n\n\n\n<li>The aliases <code>is_double()<\/code>, <code>is_long()<\/code>, <code>is_integer()<\/code> and <code>doubleval()<\/code> (use <code>is_float()<\/code>, <code>is_int()<\/code> and <code>floatval()<\/code>)<\/li>\n\n\n\n<li><code>spl_object_hash()<\/code> in favour of <code>spl_object_id()<\/code><\/li>\n\n\n\n<li><code>strcoll()<\/code> and <code>SORT_LOCALE_STRING<\/code> (use the intl <code>Collator<\/code> class)<\/li>\n\n\n\n<li>Passing an object where an array is expected to <code>array_walk()<\/code>, <code>http_build_query()<\/code> and similar functions<\/li>\n\n\n\n<li>Using <code>let<\/code> or <code>is<\/code> as a class, function or constant name<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Behaviour changes:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Sessions are more secure by default: <code>session.use_strict_mode<\/code> and <code>session.cookie_httponly<\/code> are on, and <code>session.cookie_samesite<\/code> is set to <code>Lax<\/code><\/li>\n\n\n\n<li>Custom session handlers that don&#8217;t implement both <code>create_sid()<\/code> and <code>validateId()<\/code> are deprecated<\/li>\n\n\n\n<li><code>fclose()<\/code>, <code>file_put_contents()<\/code> and <code>copy()<\/code> now return <code>false<\/code> if flushing or closing fails<\/li>\n\n\n\n<li>Many functions now throw a <code>ValueError<\/code> for out-of-range values, invalid flags or strings with NUL bytes<\/li>\n\n\n\n<li><code>trim()<\/code>, <code>ltrim()<\/code> and <code>rtrim()<\/code> now strip form feed characters by default<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If you run WordPress or another CMS, check that your theme and plugins support PHP 8.6 before switching your live site. The official <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/www.php.net\/manual\/en\/migration86.php\">migration guide<\/a> has the full list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to switch to PHP 8.6 on 20i<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to My20i and go straight to the <a href=\"https:\/\/my.20i.com\/services\/bulk-php-management\" target=\"_blank\" rel=\"noopener\">PHP Version Manager<\/a><\/li>\n\n\n\n<li>Select the sites you want to update<\/li>\n\n\n\n<li>Choose <strong>PHP 8.6<\/strong> and save<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The change takes effect straight away. If anything doesn&#8217;t look right, you can switch back to your previous version from the same screen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Top tip:<\/strong> test first on a staging site or a copy of your site, especially if you&#8217;re jumping up from PHP 8.4 or earlier.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ready when you are<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PHP 8.6 is faster, safer and more expressive, and it&#8217;s ready to use across 20i hosting right now. Not hosting with us yet? <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/www.20i.com\/\">Explore 20i hosting<\/a> and get the latest PHP from day one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you need a hand upgrading, our support team is available 24\/7.<\/p>\n","protected":false},"excerpt":{"rendered":"PHP 8.6 is available on 20i hosting. You can switch your sites over today from My20i, in just&hellip;","protected":false},"author":13,"featured_media":20964,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"csco_singular_sidebar":"","csco_page_header_type":"","csco_page_load_nextpost":"","footnotes":""},"categories":[46],"tags":[],"class_list":["post-20957","post","type-post","status-publish","format-standard","has-post-thumbnail","category-20i","cs-entry"],"_links":{"self":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts\/20957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/comments?post=20957"}],"version-history":[{"count":2,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts\/20957\/revisions"}],"predecessor-version":[{"id":20980,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts\/20957\/revisions\/20980"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/media\/20964"}],"wp:attachment":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/media?parent=20957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/categories?post=20957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/tags?post=20957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}