PHP 8.6.0 was released on 19 November 2026[1][2], and the php.net announcement calls it “a major update to the PHP language”[2]. The headline PHP 8.6 new features are partial function application, a built-in clamp() function, a Time\Duration class, a SortDirection enum, default values for readonly properties, a new polling API (Io\Poll), opt-in exceptions for stream errors, and new reflection methods[1].
This guide is written for beginner web developers. For each main feature you will see the PHP 8.5 way first, then the PHP 8.6 way, with every line explained and a short list of gotchas. After the features you will find a “Will my code break?” checklist, the support timeline, and an honest look at how to try PHP 8.6 today if you are learning on Indian shared hosting.
A note on the code
The examples below have not been run. They are untested, they are based on the official php.net documentation, and they need PHP 8.6.0 or newer. Examples marked as from the manual or release page show php.net’s documented output; the others are our own illustrations based on the documented behaviour.
PHP 8.6 at a glance
Here is the short version of what’s new in PHP 8.6, as listed on the official release page[1]:
- Partial function application (PFA): create a new function by filling in only some arguments of an existing one.
clamp(): keep a number (or any comparable value) between a minimum and a maximum.Time\Duration: a dedicated class for lengths of time, with nanosecond precision.SortDirectionenum: a standardAscending/Descendingtype.- Readonly property defaults:
public readonly int $timeout = 30;is now allowed. Io\Poll: a polling API for watching many streams at once.- Stream error handling: stream functions can throw exceptions instead of warnings.
- Reflection additions:
ReflectionProperty::isReadable()/isWritable()and doc comments on parameters.
On the same day, php.net also shipped security updates for older branches: 8.5.13, 8.4.28, 8.3.37 and 8.2.36[2]. If you are not ready to move to 8.6, you should still keep your current version patched.
The official migration guide, “Migrating from PHP 8.5.x to PHP 8.6.x”, collects new features, new classes and functions, backward incompatible changes and deprecations in one place[3]. This article is a friendlier walkthrough of the parts that matter most to beginners.
Before you start: prerequisites
You will get the most from this guide if you already know:
- How to write and call a PHP function, including default parameter values.
- How arrays and basic array functions such as
array_filter()work. - How to create a simple class with properties and a constructor.
- How to run a PHP file from the terminal (
php file.php) or through a local server.
To run the PHP 8.6 examples you need PHP 8.6.0 or newer. The section “How to try PHP 8.6 today” near the end explains how to check your version and what to do if your host does not offer 8.6 yet.
Five terms you will see in this guide
- Closure: PHP’s object type for anonymous functions. Partial function application gives you a
Closure[4]. - Arrow function: the short
fn($x) => $x * 2syntax. Its body runs every time you call it. - First-class callable syntax: writing
strlen(...)to get aClosurethat points atstrlen. PHP 8.6 treats this as the simplest case of partial function application[4]. - Pipe operator
|>: added in PHP 8.5. It passes the value on its left into a one-argument callable on its right[4]. - Enum: a type with a fixed list of named cases, such as
SortDirection::Ascending.
Partial function application: fill in some arguments now, the rest later
Partial function application (PFA) is the biggest change in PHP 8.6. When a function call contains a placeholder, PHP does not run the function. Instead it returns a Closure that waits for the missing arguments[4][5].
There are two placeholders[4]:
?stands for exactly one argument....stands for all remaining arguments.
The PHP 8.5 way
Say you have a function that adds numbers, and you want a version that always adds 1. In PHP 8.5 you would wrap it in an arrow function:
<?php
function add(int $a, int $b, int $c = 0): int
{
return $a + $b + $c;
}
// PHP 8.5: wrap the call in an arrow function
$addOne = fn(int $b): int => add(1, $b);
var_dump($addOne(5)); // int(6)Line by line: add() takes two required numbers and an optional third one. The arrow function fixes $a to 1 and passes $b through. Calling $addOne(5) runs add(1, 5), which returns 6.
The PHP 8.6 way
In PHP 8.6 you can write the same thing with a placeholder. This example comes from the official PHP 8.6 manual[6]:
<?php
function add(int $a, int $b, int $c = 0): int
{
return $a + $b + $c;
}
// PHP 8.6: "?" leaves one argument open
$addOne = add(1, ?);
var_dump($addOne(5)); // int(6)
// PHP 8.6: "..." leaves all remaining arguments open
$addToOne = add(1, ...);
var_dump($addToOne(2, 3)); // int(6)
// Works with built-in functions too
$removeSpaces = str_replace(' ', '', ?);
var_dump($removeSpaces('a b c')); // string(3) "abc"What is happening here:
add(1, ?)does not calladd(). It returns aClosurewith one parameter, which fills the?slot.$addOne(5)finally runsadd(1, 5).add(1, ...)returns aClosurethat accepts everything after the first argument, so$addToOne(2, 3)runsadd(1, 2, 3).str_replace(' ', '', ?)fixes the search and replace strings and leaves the subject open[6].
The manual describes volume(2, ?, 4) as equivalent to static fn(int $width): int => volume(2, $width, 4)[4]. In other words, PFA writes the arrow function for you, and the new closure keeps the original parameter names, types and return type[4][5].
Using it with array_filter()
The release page shows a practical example: keeping only version strings that are 8.6 or higher[1].
<?php
$versions = ['8.4', '8.5', '8.6', '8.7'];
// PHP 8.5 way
$modern = array_filter($versions, fn($version) => version_compare($version, '8.6', '>='));
// PHP 8.6 way
$modern = array_filter($versions, version_compare(?, '8.6', '>='));
print_r($modern);Both lines do the same job. In the 8.6 version, version_compare(?, '8.6', '>=') becomes a one-argument closure, and array_filter() calls it once for each version. Remember that array_filter() keeps the original array keys, so the result here has keys 2 and 3, not 0 and 1.
Using it with the pipe operator
PFA pairs naturally with the pipe operator from PHP 8.5, because each pipe step needs a one-argument callable. This chain is from the manual[4]:
<?php
$result = ' Hello World '
|> trim(...)
|> str_replace(' ', '', ?)
|> strtoupper(...)
|> str_pad(?, 12, '*', STR_PAD_BOTH);
echo $result; // *HELLOWORLD*Read it from top to bottom. trim(...) removes the outer spaces, str_replace(' ', '', ?) removes the inner spaces, strtoupper(...) makes the text uppercase, and str_pad(?, 12, '*', STR_PAD_BOTH) pads it to 12 characters with stars on both sides[4].
PHP 8.6 also compiles array_map() calls that use first-class callable or partial application callbacks into loops, as one of several performance improvements[1]. PFA co-author Larry Garfield has written that pipe optimisations mean the closure does not even need to be created in those cases; that is his statement, not a published benchmark[7].
Gotchas
- Bound arguments are evaluated once, when the closure is created. An arrow function runs its argument expressions on every call, but PFA evaluates them up front[4][5]. See the example below.
?is always required. Even if the original parameter was optional, a?slot becomes a required parameter. Parameters covered by...keep their defaults[4].- Extra arguments are ignored without
.... If you pass more arguments than there are?slots, they are dropped. With..., they are forwarded to the original function[4][5]. - Wrong counts fail early. If the arguments plus placeholders do not match the function’s parameters, PHP throws an
ArgumentCountErrorwhen the closure is created, not when it is called[4][5]. ...can appear only once, and it must come last[4].- Not everywhere. PFA does not work with
newexpressions, cannot be combined with the nullsafe operator?->or argument unpacking, and cannot be used withcompact(),extract(),func_get_args()orget_defined_vars()[4][5].
Here is the evaluation-time gotcha in code:
<?php
function stamp(string $time, string $message): string
{
return "[$time] $message";
}
// Arrow function: date() runs on EVERY call
$logNow = fn(string $message): string => stamp(date('H:i:s'), $message);
// Partial application: date() runs ONCE, right here
$logFixed = stamp(date('H:i:s'), ?);
echo $logNow('Saved'), "\n";
sleep(2);
echo $logNow('Saved again'), "\n";
// [10:00:00] Saved
// [10:00:02] Saved again (times are examples)
echo $logFixed('Saved'), "\n";
sleep(2);
echo $logFixed('Saved again'), "\n";
// [10:00:00] Saved
// [10:00:00] Saved again (the time $logFixed was created; times are examples)Both closures still need the $message argument, because a ? slot is always required[4]. If you call $logNow('...') a few seconds apart, each line gets a fresh time. If you call $logFixed('...'), every line shows the time when $logFixed was created. So when an argument depends on the current time, a counter or anything with side effects, keep the arrow function.
Named placeholders such as str_replace(subject: ?, search: ?, replace: '') are also allowed, and the new closure’s parameters follow the order you write them in[4]. That can reorder parameters, so as a beginner it is usually clearer to stick to positional ? placeholders.
clamp(): keep a value inside a range
Does PHP have a clamp function? Yes, from PHP 8.6.0. Its signature is clamp(mixed $value, mixed $min, mixed $max): mixed[8][9]. It returns $value if it lies between $min and $max (both inclusive); otherwise it returns the nearest bound[8].
The PHP 8.5 way
<?php
$requested = 110;
// PHP 8.5: limit a percentage-style value to 0..100
$volume = max(0, min(100, $requested));
var_dump($volume); // int(100)Read it inside out: min(100, 110) gives 100, then max(0, 100) gives 100. It works, but it is easy to swap min and max by mistake.
The PHP 8.6 way
<?php
var_dump(clamp(110, 0, 100)); // int(100)
var_dump(clamp(2.5, 1, 3)); // float(2.5)
var_dump(clamp(0, 1.3, 3.4)); // float(1.3)
var_dump(clamp("J", min: "A", max: "F")); // string(1) "F"What each line shows:
clamp(110, 0, 100)returns the upper bound100, the same result as themax()/min()version[1][9].clamp(2.5, 1, 3)returns2.5unchanged.clamp()gives back the original argument without converting its type[9].clamp(0, 1.3, 3.4)returns the lower bound1.3, which is a float[9].- Strings work too, using PHP’s normal comparison rules. Named arguments
min:andmax:make the call easier to read[8].
clamp() works with any comparable values, including DateTimeImmutable objects[8].
Gotchas
$mingreater than$maxthrows aValueErrorwith the message “clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max)”[8][9].- A
NANbound throws aValueError. If$valueitself isNAN,clamp()returnsNAN[8][9]. - Mixing types can surprise you. The manual warns that comparing different types can give unpredictable results, so keep the value and both bounds the same type[8].
<?php
try {
clamp(5, 10, 1); // min (10) is bigger than max (1)
} catch (ValueError $e) {
echo $e->getMessage();
}This prints the ValueError message quoted above. In real code, the bounds often come from user settings or a form, so validate them (or catch the error) before calling clamp().
If your project must also run on PHP 8.0 to 8.5, you can add a simple fallback. (ValueError exists only from PHP 8.0, so on PHP 7.x throw InvalidArgumentException instead.) It is an approximation, not a full copy of the built-in function:
<?php
if (!function_exists('clamp')) {
function clamp($value, $min, $max)
{
if ($min > $max) {
throw new ValueError('clamp(): $min must be smaller than or equal to $max');
}
return max($min, min($max, $value));
}
}function_exists('clamp') is false on older versions, so the fallback is defined only there. On PHP 8.6 the built-in function is used and this block is skipped. The fallback does not copy every detail, such as the NAN checks.
Time\Duration: a proper type for lengths of time
Time\Duration represents an amount of elapsed time, like a stopwatch reading, with nanosecond precision[10][11]. It is a final readonly class with three public properties: int $seconds, int $nanoseconds and bool $negative. Its constructor is private, so you create durations with static factory methods[10][11].
The factories are fromSeconds(), fromNanoseconds(), fromMicroseconds(), fromMilliseconds(), fromMinutes(), fromHours() and fromIso8601DurationString(). The methods are add(), sub(), multiplyBy(), divideBy(), negate(), absolute() and a static compare()[10][11].
The PHP 8.5 way
Before 8.6, most code stored time spans as plain integers:
<?php
// PHP 8.5: is this seconds or milliseconds? Only the variable name tells you.
$timeoutMs = 2 * 1000 + 500;
echo $timeoutMs / 1000 . " seconds\n"; // 2.5 secondsThe number 2500 carries no unit. If one function expects seconds and another expects milliseconds, nothing stops you passing the wrong one.
The PHP 8.6 way
This example is adapted from the PHP 8.6 manual[6]:
<?php
use Time\Duration;
$total = Duration::fromSeconds(2)->add(Duration::fromMilliseconds(500));
printf("%d.%09d seconds\n", $total->seconds, $total->nanoseconds);
// 2.500000000 seconds
var_dump($total > Duration::fromSeconds(2)); // bool(true)Line by line:
use Time\Duration;imports the class from theTimenamespace, so you can writeDurationinstead of\Time\Duration.Duration::fromSeconds(2)creates a two-second duration, and->add(...)returns a new duration that is 500 milliseconds longer. The original objects never change.printf()prints the whole seconds and the nanoseconds part, giving2.500000000 seconds[6].- Durations can be compared with operators such as
>and<, so the last line givesbool(true)[6][11].
Because durations are comparable, min() works on them directly, and so does clamp(). The release page shows that clamp(Duration::fromSeconds(30), min: Duration::fromMinutes(1), max: Duration::fromMinutes(10))->seconds gives int(60)[1].
To subtract, use sub():
<?php
use Time\Duration;
$limit = Duration::fromMinutes(10);
$used = Duration::fromSeconds(90);
$left = $limit->sub($used);
echo $left->seconds; // 510Ten minutes is 600 seconds; minus 90 seconds leaves 510. Again, sub() returns a new object and leaves $limit untouched.
Gotchas
- The method is
sub(), notsubtract()[10][11]. - You cannot use
new Duration(...). The constructor is private; use afrom...()factory[10][11]. - Factories reject negative numbers. To get a negative duration, create a positive one and call
->negate().multiplyBy()does not accept a negative factor, anddivideBy()needs a positive divisor and drops fractional nanoseconds[11]. +and-do not work on durations. Comparison operators are supported, but arithmetic operators are not overloaded, so useadd()andsub(). Operations that overflow throwTime\TimeException[11][6].sleep()does not accept aDuration. Existing functions were not changed. The release page converts withtime_nanosleep($delay->seconds, $delay->nanoseconds)[11][1].
SortDirection: a shared enum for sort order
SortDirection is a pure (unbacked) enum in the global namespace with two cases: SortDirection::Ascending and SortDirection::Descending[12]. Pure means the cases have no integer or string value attached; you compare the cases themselves.
The PHP 8.5 way
Without a shared type, sort order was often an int flag or a bool:
<?php
// PHP 8.5: any int is accepted, even a meaningless one
function sortPrices(array $prices, int $order = SORT_ASC): array
{
if ($order === SORT_DESC) {
rsort($prices);
} else {
sort($prices);
}
return $prices;
}
print_r(sortPrices([300, 100, 200], SORT_STRING)); // silently sorts ascendingSORT_STRING is a sorting flag, not a direction, but the function accepts it because it is just an integer. The mistake goes unnoticed.
The PHP 8.6 way
<?php
function sortPrices(array $prices, SortDirection $direction = SortDirection::Ascending): array
{
if ($direction === SortDirection::Descending) {
rsort($prices);
} else {
sort($prices);
}
return $prices;
}
echo implode(', ', sortPrices([300, 100, 200], SortDirection::Descending)); // 300, 200, 100Now the parameter type is SortDirection, so only Ascending or Descending can be passed. The release page points out that type-hinting a parameter this way turns a mistake like passing SORT_STRING into an immediate TypeError, instead of an int flag that is accepted and fails later[1].
Gotchas
- No built-in function accepts
SortDirectionyet. You cannot pass it tosort()orusort(); future use in functions likescandir()is listed as future scope[12][13]. For now it is mainly for your own functions and for libraries. - Why add it at all? The PHP Foundation reports that a GitHub search found more than 150 incompatible userland versions of the same idea, so a shared standard type helps libraries agree[14].
Readonly properties can now have default values
A readonly property can be set only once. Until PHP 8.6, readonly properties could not have a default value, so you had to set them in the constructor. Now instance readonly properties, including those in readonly classes, can declare a default[6][15][1].
The PHP 8.5 way
<?php
class Config
{
public readonly int $timeout;
public function __construct()
{
$this->timeout = 30;
}
}
echo (new Config())->timeout; // 30You declare the property, then assign 30 inside the constructor. That is a lot of code for a fixed value.
The PHP 8.6 way
<?php
class Config
{
public readonly int $timeout = 30;
}
echo (new Config())->timeout; // 30The default is written right on the property, just like a normal property, and it still cannot be changed later.
Gotchas
<?php
class Config
{
public readonly int $timeout = 30;
public function __construct(int $timeout)
{
$this->timeout = $timeout; // Error: the default already initialised it
}
}If you need a value that the caller can override, do not give the property a default. Use a promoted constructor parameter with a default instead, such as public function __construct(public readonly int $timeout = 30) {}. That default is only a parameter default, so the constructor still sets the property once[15].
- Cloning is the exception. Inside
__clone(), a defaulted readonly property may be reinitialised once[15].
Other PHP 8.6 features worth knowing
These features matter more to framework and library authors than to most beginners, so here is a short summary of each.
Io\Poll: watching many streams at once
The new Io\Poll API adds the Context and Watcher classes, the Backend and Event enums and the Handle interface in the Io\Poll namespace, plus a global StreamPollHandle class[6][16]. It automatically picks the best mechanism for your operating system: epoll on Linux, kqueue on BSD and macOS, event ports on Solaris/illumos, or WSAPoll on Windows[16][1].
It avoids the select()-based limit of stream_select(), which is typically about 1024 connections, but it is not an event loop and does not add async features[1][13]. If you build normal web pages that run under PHP-FPM, you are unlikely to need it. If you are curious, start with the release page example, which calls wait() without arguments[1].
Exceptions for stream errors
By default, stream functions such as file_get_contents() still emit warnings. In PHP 8.6 you can ask for exceptions instead through the stream context option 'stream' => ['error_mode' => StreamErrorMode::Exception][17][1].
<?php
$context = stream_context_create([
'stream' => ['error_mode' => StreamErrorMode::Exception],
]);
try {
$data = file_get_contents('missing-file.txt', false, $context);
} catch (StreamException $e) {
echo 'Could not read the file: ' . $e->getMessage();
}The context switches error handling to exception mode, so a failed read throws a StreamException that you can catch. $e->getErrors() returns StreamError objects with the details. The default mode, StreamErrorMode::Error, keeps the old warnings, so existing code is not affected[17][1].
Reflection and doc comment additions
ReflectionProperty::isReadable(?string $scope, ?object $object = null): boolandisWritable(?string $scope, ?object $object = null): booltell you whether a property can be read or written from a given scope[18][1].ReflectionParameter::getDocComment(): string|falselets each function parameter carry its own doc comment[19][1].
Smaller improvements
#[\Override]can be used on class constants and enum cases, and enums can define__debugInfo()[6][1].- Properties of objects stored in constants can be assigned directly, for example
CONFIG->debug = true[6][1]. pack()andunpack()accept<and>endianness modifiers[1][6].- JSON error messages now include the error location, and there are new functions and methods:
mysqli::quote_string(),grapheme_strrev()andZipArchive::openString()[1].
Will my code break? A PHP 8.6 upgrade checklist
Most beginner code will keep working, but check these items before you switch a project to PHP 8.6.
Behaviour changes
- [ ]
trim(),ltrim()andrtrim()now strip the form feed character (\f) by default.trim("\f hello \f")givesstring(5) "hello"in 8.6[20][1]. If you relied on\fsurviving, pass your own character list. - [ ] Session defaults are stricter.
session.use_strict_mode=1,session.cookie_httponly=1andsession.cookie_samesite="Lax"are now the defaults[20][1]. JavaScript can no longer read the session cookie throughdocument.cookie, and some cross-site flows may stop sending the cookie. If your front end reads the session cookie, change that design rather than turning the protection off. - [ ] More
ValueErrors. Out-of-range values passed tonumber_format()(decimals),sleep()andusleep()now throwValueError. Invalid flags forarray_filter(),array_change_key_case(),pathinfo()andscandir()also throw, and so do NUL bytes in paths passed tofile_exists(),is_file()and similar functions[20]. - [ ]
unpack()format keys. In a format like's<value', the<is now an endianness modifier, so the result key changes from'<value'to'value'[20]. - [ ] Return values when closing files.
fclose(),file_put_contents()andcopy()now returnfalsewhen flushing or closing the stream fails[1]. If you check these return values, a failure you never saw before may now show up.
Deprecated features and their replacements
Deprecated features still work in PHP 8.6 but emit deprecation notices. Deprecation is PHP’s usual warning before a feature is removed in a future version; for some items, such as the mbregex functions, the manual already names PHP 9.0[21]. Here are the ones beginners are most likely to meet[21][1]:
| Deprecated in 8.6 | Use instead |
|---|---|
is_double() |
is_float() |
is_long(), is_integer() |
is_int() |
doubleval() |
floatval() |
spl_object_hash() |
spl_object_id() |
strcoll(), SORT_LOCALE_STRING |
Collator (intl extension) |
mb_ereg*(), mb_split() |
preg_*() with the u modifier |
return inside finally |
Return before or after the try block |
Returning a value from __construct() / __destruct() |
Return nothing |
Third argument of define() |
Remove it |
Also note that let and is are deprecated as class, function and constant names[21]. The mbregex functions are planned for removal in PHP 9.0, so replacing them now saves work later[21].
How long is PHP 8.6 supported?
| Version | Active support until | Security support until |
|---|---|---|
| PHP 8.6 | 31 Dec 2028 | 31 Dec 2030 |
| PHP 8.5 | 31 Dec 2027 | 31 Dec 2029 |
| PHP 8.4 | 31 Dec 2026 | 31 Dec 2028 |
| PHP 8.2 | ended | 31 Dec 2026 |
These dates come from php.net’s supported versions page[22]. PHP 8.6 gets active support until 31 Dec 2028 and security fixes until 31 Dec 2030[22].
What this means for you:
- Learning PHP now? PHP 8.6 has the longest support window, so it is a good version to learn on if you can install it.
- Running a project on 8.4 or 8.5? Both are still supported, so there is no rush. Upgrade when your libraries and host are ready[22].
- On 8.3? It received a security release (8.3.37) on the same day as 8.6.0[2], so it still gets security fixes. Check php.net’s supported versions page for its end date[22] and plan a move to 8.4 or newer.
- Still on 8.2? Its security support ends on 31 Dec 2026, so plan an upgrade soon[22].
- On 8.1 or older? Check php.net’s supported versions page[22] to see whether your version still gets any fixes, and upgrade if it does not.
Should you upgrade production on release day? The migration guide recommends testing your code before switching PHP versions in production[3]. Try it locally first, fix the checklist items above, then upgrade.
How to try PHP 8.6 today
Step 1: check your current version. In a terminal, run php -v. In a web page, you can print the version:
<?php
echo PHP_VERSION; // for example "8.5.13" or "8.6.0"
if (PHP_VERSION_ID < 80600) {
echo "\nThe examples in this guide need PHP 8.6.0 or newer.";
}PHP_VERSION is the version as text, and PHP_VERSION_ID is a number you can compare (80600 means 8.6.0). Keep this check in a separate file from any PFA code: older PHP versions cannot even read the ? placeholder syntax, so a file that uses it fails before your check can run.
Step 2: check your hosting. Many beginners in India learn on cPanel-based shared hosting. cPanel’s EasyApache 4 documentation, last modified in July 2026, lists support for PHP 7.4 and 8.1 through 8.5 and does not mention 8.6[23]. We could not confirm whether Indian shared hosts offer PHP 8.6 yet, so open your host’s PHP version selector or ask their support team. Do not assume it is there.
Step 3: try it locally if your host does not have it. Install PHP 8.6 on your own computer, or use a container or local stack that provides it. Check the exact PHP version your tool offers before you start, because not every local bundle updates on release day.
Step 4: keep production safe. Run your project on 8.6 locally, work through the “Will my code break?” checklist, and switch your live site only after it behaves correctly[3]. If you run WordPress, check that WordPress core, your theme and your plugins list PHP 8.6 compatibility before you switch; we could not confirm their status at the time of writing.
Frequently asked questions
When was PHP 8.6 released?
PHP 8.6.0 was released on 19 November 2026[1][2].
What is the difference between PHP 8.6 and PHP 8.5?
PHP 8.6 adds partial function application, clamp(), Time\Duration, SortDirection, readonly property defaults, Io\Poll and exception-based stream errors, plus stricter session defaults and a new set of deprecations[1][20][21].
Can I keep using PHP 8.5?
Yes. PHP 8.5 receives active support until 31 Dec 2027 and security fixes until 31 Dec 2029[22].
Conclusion
PHP 8.6 is a big release, but you do not have to learn it all at once. Start with the features you will use every day: clamp() for keeping values in range, readonly defaults for simpler classes, and partial function application for shorter callbacks. Just remember that PFA evaluates its fixed arguments once. Add Time\Duration and SortDirection when you write functions that deal with time or sort order. Before upgrading a real project, work through the checklist, test locally, and confirm that your host offers 8.6.
To keep learning, find more beginner-friendly PHP, JavaScript and WordPress tutorials on Veducator.
Before you go
Key takeaways
- PHP 8.6.0 was released on 19 November 2026, with active support until 31 Dec 2028 and security fixes until 31 Dec 2030.
- Partial function application uses
?for exactly one argument and...for the rest. Bound arguments are evaluated once, when the closure is created. clamp()keeps a value between a minimum and a maximum, and throws aValueErrorif$minis greater than$max.Time\Durationgives lengths of time their own type. Useadd()andsub(), not+and-.- Readonly properties can now have default values, and
SortDirectiongives sort order a standard enum. - Before upgrading a real project, work through the checklist, test locally and confirm your host offers PHP 8.6.
Sources
- PHP 8.6 Release Announcement, The PHP Group (php.net).
- PHP homepage news: PHP 8.6.0 Released!, The PHP Group (php.net).
- PHP Manual: Migrating from PHP 8.5.x to PHP 8.6.x, The PHP Group (php.net).
- PHP Manual: Partial function application, The PHP Group (php.net).
- PHP RFC: Partial Function Application (v2), PHP wiki (Larry Garfield, Arnaud Le Blanc).
- PHP Manual: PHP 8.6 New Features, The PHP Group (php.net).
- PHP 8.6 kicks off with partial function application, The PHP Foundation (Larry Garfield).
- PHP Manual: clamp, The PHP Group (php.net).
- PHP RFC: clamp v2, PHP wiki (kylekatarnls).
- PHP Manual: The Time\Duration class, The PHP Group (php.net).
- PHP RFC: Duration class, PHP wiki (Tim Düsterhus, Derick Rethans).
- PHP RFC: SortDirection enum, PHP wiki (Tim Düsterhus).
- What’s new in PHP 8.6, stitcher.io.
- Standard library investment (SortDirection, Time\Duration), The PHP Foundation (Tim Düsterhus).
- PHP RFC: Readonly property defaults, PHP wiki (Nick Sdot).
- PHP RFC: Polling API, PHP wiki (Jakub Zelenka).
- PHP RFC: Stream errors, PHP wiki (Jakub Zelenka).
- PHP RFC: ReflectionProperty::isReadable() and isWritable(), PHP wiki (Ilija Tovilo, Larry Garfield).
- PHP RFC: Parameter DocComments, PHP wiki (Christian Schneider).
- PHP Manual: PHP 8.6 Backward Incompatible Changes, The PHP Group (php.net).
- PHP Manual: PHP 8.6 Deprecated Features, The PHP Group (php.net).
- PHP: Supported Versions, The PHP Group (php.net).
- EasyApache 4: About PHP, cPanel.
Comments