PHP 8.5 is a major update of the PHP language. It contains many new features, such as the new
URI
extension, support for modifying properties while cloning, the Pipe operator, performance
improvements, bug fixes, and general cleanup.
As an always-available part of PHP's standard library the new URI extension provides APIs to
parse and modify URIs and URLs according to the RFC 3986 and the WHATWG URL standards.
The secure and standards-compliant URI parsing is powered by the uriparser (RFC 3986) and Lexbor (WHATWG URL) libraries.
It is now possible to update properties during object cloning by passing an associative array
with the updated to the clone() function. This enables straight-forward support
of the "with-er" pattern for readonly classes.
The pipe operator allows chaining function calls together without dealing with intermediary
variables. That can be especially helpful when replacing many "nested calls" with a chain
that can be read forwards, rather than inside-out.
By adding the #[\NoDiscard] attribute to a function, PHP will check whether the
returned
value is
consumed and emit a warning if it is not. This allows to improve the safety of APIs where
the
returned value is important, but where it is easy to forget using the return value by
accident.
The associated (void) cast can be used to indicate that a value is intentionally
unused.
#[\NoDiscard]
function getPhpVersion(): string
{
'PHP 8.5';
}
getPhpVersion();
// No Errors
// Warning: The return value of function getPhpVersion() should either be used or intentionally ignored by casting it as (void)
New Dom\Element::getElementsByClassName() and
Dom\Element::insertAdjacentHTML() methods are available.
New enchant_dict_remove_from_session() and
enchant_dict_remove() functions are available.
New grapheme_levenshtein() function is available.
New opcache_is_script_cached_in_file_cache() function is available.
New ReflectionConstant::getFileName(),
ReflectionConstant::getExtension(),
ReflectionConstant::getExtensionName(),
ReflectionConstant::getAttributes(), and
ReflectionProperty::getMangledName() methods are available.
Deprecations and backward compatibility
breaks
There are no deprecations or compatibility breaks.
Better performance, better syntax, improved type safety.
For source downloads of PHP 8.5 please visit the downloads page.
Windows binaries can be found on the PHP for
Windows site. The list of changes is recorded in the ChangeLog.
The migration guide is available in the PHP Manual.
Please consult it for a detailed list of new features and backward-incompatible changes.