{"id":7309,"date":"2026-02-25T09:39:34","date_gmt":"2026-02-25T08:39:34","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=7309"},"modified":"2026-02-25T09:39:56","modified_gmt":"2026-02-25T08:39:56","slug":"beneficii-si-schimbari-in-php-8-5","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/ro\/knowledgebase\/benefits-and-changes-in-php-8-5\/","title":{"rendered":"Avantaje \u0219i modific\u0103ri \u00een PHP 8.5"},"content":{"rendered":"\n<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">PHP 8.5 introduces the pipe operator, URI extension, and functions array_first() and array_last(), making everyday programming easier. This version improves code readability, URL handling, and debugging, while offering performance optimizations and deprecations of unnecessary features. With these changes, you can write simpler and faster code for your websites.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/benefits-and-changes-in-php-8-5\/#New_Features_and_Improvements\" >New Features and Improvements<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/benefits-and-changes-in-php-8-5\/#Pipe_Operator_%3E\" >Pipe Operator |&gt;<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/benefits-and-changes-in-php-8-5\/#URI_Extension\" >URI Extension<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/benefits-and-changes-in-php-8-5\/#array_first_and_array_last_Functions\" >array_first() and array_last() Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/benefits-and-changes-in-php-8-5\/#NoDiscard_Attribute\" >#[\\\\NoDiscard] Attribute<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/benefits-and-changes-in-php-8-5\/#Cloning_with_Property_Modification\" >Cloning with Property Modification<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/benefits-and-changes-in-php-8-5\/#get_error_handler_and_get_exception_handler_Functions\" >get_error_handler() and get_exception_handler() Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/benefits-and-changes-in-php-8-5\/#Other_Useful_Additions\" >Other Useful Additions<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/benefits-and-changes-in-php-8-5\/#Deprecations_and_Fixes\" >Deprecations and Fixes<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"New_Features_and_Improvements\"><\/span>New Features and Improvements<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Pipe_Operator_%3E\"><\/span>Pipe Operator |&gt;<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The pipe operator |>, long-awaited by PHP developers, enables chaining function calls from left to right without intermediate variables. Instead of nested calls like <strong>strtolower(str_replace(&#8216; &#8216;, &#8216;-&#8216;, trim($title)))<\/strong>, you can simply write <strong>$title |> trim($$) |> str_replace(&#8216; &#8216;, &#8216;-&#8216;, $$) |> strtolower($$)<\/strong>. This makes code more readable and maintainable, especially for complex data operations.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"URI_Extension\"><\/span>URI Extension<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<\/div>\n\n<div id=\"mybox-3312260701\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Early access<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Still need help?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contact our customer service team.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Message us<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">PHP 8.5 adds a built-in URI extension for parsing and normalizing URLs compliant with RFC 3986 and WHATWG URL standards. You can now safely handle links without extra libraries, for example, using the Uri\\Rfc3986\\Uri class to extract the host from &#8216;https:\/\/php.net&#8217;. This greatly simplifies URL work in web applications and reduces error risks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"array_first_and_array_last_Functions\"><\/span>array_first() and array_last() Functions<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The new array_first() and array_last() functions let you quickly retrieve the first or last array element, returning null if the array is empty. Instead of combining array_key_last() or end(), just use array_last($events). These simple additions save time and organize code when working with data lists.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"NoDiscard_Attribute\"><\/span>#[\\\\NoDiscard] Attribute<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The #[\\\\NoDiscard] attribute generates a warning when you ignore a function&#8217;s return value, helping avoid API mistakes. For example, a getPhpVersion() function with this attribute will trigger a warning if you don&#8217;t use its result, unless you explicitly use (void)getPhpVersion(). This tool improves code quality and security.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Cloning_with_Property_Modification\"><\/span>Cloning with Property Modification<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can now clone an object and immediately modify selected properties by passing an associative array to clone(), like clone($this, [&#8216;alpha&#8217; => $alpha]). This solution is perfect for readonly classes and simplifies the &#8220;with-er&#8221; pattern without manual data copying. Previously, it required extra logic in methods like withAlpha().<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"get_error_handler_and_get_exception_handler_Functions\"><\/span>get_error_handler() and get_exception_handler() Functions<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The get_error_handler() and get_exception_handler() functions allow checking current error and exception handlers during program execution. They facilitate debugging and understanding app behavior. They also support stack traces for fatal errors, speeding up problem resolution.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Other_Useful_Additions\"><\/span>Other Useful Additions<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">PHP 8.5 adds constants PHP_BUILD_DATE and PHP_BUILD_PROVIDER for build date checks, the CLI option php &#8211;ini=diff to show INI changes, and locale_is_right_to_left() for right-to-left languages like Arabic. The curl_multi_get_handles() function helps manage cURL sessions, and persistent cURL handles speed up initialization.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Deprecations_and_Fixes\"><\/span>Deprecations and Fixes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PHP 8.5 ends support for old casts like (boolean) or (integer) \u2013 use (bool) and (int) instead. Functions like curl_close(), xml_parser_free(), and socket_set_timeout() are deprecated as unnecessary. The disable_classes INI directive is removed, and switch case statements now require a colon. These changes clean up the language and prepare for future versions.<\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[25,39,53],"manual_kb_tag":[4215,4216,4217,4218,4219,4220,4221,4222,4223],"class_list":["post-7309","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-hosting","manualknowledgebasecat-php-operations","manualknowledgebasecat-servers","manual_kb_tag-array_first-php","manual_kb_tag-php-8-5-fixes","manual_kb_tag-uri-extension-php","manual_kb_tag-php-update","manual_kb_tag-php-8-5-benefits","manual_kb_tag-php-8-5-deprecations","manual_kb_tag-php-8-5","manual_kb_tag-pipe-operator-php","manual_kb_tag-new-php-8-5-features"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/7309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":2,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/7309\/revisions"}],"predecessor-version":[{"id":7310,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/7309\/revisions\/7310"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/media?parent=7309"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manualknowledgebasecat?post=7309"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb_tag?post=7309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}