{"id":700,"date":"2021-09-08T13:24:17","date_gmt":"2021-09-08T13:24:17","guid":{"rendered":"https:\/\/www.capconnect.com\/blog\/?p=700"},"modified":"2021-09-08T20:06:09","modified_gmt":"2021-09-08T20:06:09","slug":"php-8","status":"publish","type":"post","link":"https:\/\/www.capconnect.com\/blog\/en\/php-8\/","title":{"rendered":"PHP 8 is now available! All you need to know about the new features!"},"content":{"rendered":"<p>The PHP language has once again been updated. As a matter of fact, the PHP 8 version was launched in 2020 and is currently the most recent version that has been made available to the public.<br \/>\nThis version not only resolves some issues that have arisen and appeared in previous versions, but also brings several optimizations, developments, features and novelties.<br \/>\nThis does not mean that previous versions are obsolete or dysfunctional. This simply means that by adopting the PHP 8 update, you choose to benefit from multiple new interesting possibilities for your site. With that said, the new functions offer several advantages and the flaws are better managed.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_38 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Table de mati&egrave;res<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><label for=\"item\" aria-label=\"Table des mati\u00e8res\"><span style=\"display: flex;align-items: center;width: 35px;height: 30px;justify-content: center;\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/label><input type=\"checkbox\" id=\"item\"><\/a><\/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:\/\/www.capconnect.com\/blog\/en\/php-8\/#What_is_PHP\" title=\"What is PHP?\">What is PHP?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.capconnect.com\/blog\/en\/php-8\/#PHP_8s_features\" title=\"PHP 8&rsquo;s features\">PHP 8&rsquo;s features<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"What_is_PHP\"><\/span>What is PHP?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Hypertext Preprocessor or <a href=\"https:\/\/www.php.net\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">PHP<\/a> is a scripting language, or, in other terms, a programming language free of websites. It makes it possible to create dynamic websites, also known as moving ones.<br \/>\nBeing fast, flexible and pragmatic, this language can be used for any type of site, as well as for very known and often used websites such as Facebook.<br \/>\nTo benefit from the PHP language, you must first have a <a href=\"https:\/\/www.capconnect.com\/en\/domain-names\" target=\"_blank\" rel=\"noopener noreferrer\">domain name<\/a> (<a title=\".ma domain name\" href=\"https:\/\/www.capconnect.com\/en\/morocco-domain-name\" target=\"_blank\" rel=\"noopener noreferrer\">.ma domain name<\/a>) and a solid <a href=\"https:\/\/www.capconnect.com\/en\/web-hosting\" target=\"_blank\" rel=\"noopener noreferrer\">web hosting<\/a> formula.<br \/>\nYou can increase and\/or change the current PHP version adopted for your website at any time.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-703 size-medium\" title=\"PHP 8\" src=\"https:\/\/www.capconnect.com\/blog\/wp-content\/uploads\/2021\/09\/PHP-8-release-1-300x188.png\" alt=\"PHP 8\" width=\"300\" height=\"188\" srcset=\"https:\/\/www.capconnect.com\/blog\/wp-content\/uploads\/2021\/09\/PHP-8-release-1-300x188.png 300w, https:\/\/www.capconnect.com\/blog\/wp-content\/uploads\/2021\/09\/PHP-8-release-1-1024x640.png 1024w, https:\/\/www.capconnect.com\/blog\/wp-content\/uploads\/2021\/09\/PHP-8-release-1-768x480.png 768w, https:\/\/www.capconnect.com\/blog\/wp-content\/uploads\/2021\/09\/PHP-8-release-1-1170x731.png 1170w, https:\/\/www.capconnect.com\/blog\/wp-content\/uploads\/2021\/09\/PHP-8-release-1-585x366.png 585w, https:\/\/www.capconnect.com\/blog\/wp-content\/uploads\/2021\/09\/PHP-8-release-1.png 1280w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"PHP_8s_features\"><\/span>PHP 8&rsquo;s features<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The most important and remarkable advantage that PHP 8 offers is the JIT compilation (Just in time), also called on-the-fly compilation or just-in-time compilation.<br \/>\nJIT compilation is a technique that improves the performance and efficiency of compiled systems based on bytecode. In fact, it allows to translate the bytecode, originally derived from a source code that is difficult to interpret, immediately at the time of execution.<br \/>\nThe point of this is basically to obtain an optimized code from bytecode rather than from source code. This technique is particularly effective when it comes to compiling a hot code, that is to say the code most used at a time and the one that requires the most memory.<br \/>\nThis compilation allows considerable and interesting improvements at the PHP level, in a way that several functions can now be written directly.<br \/>\nIn addition to JIT compilation, many other new features that make PHP much more efficient are currently available . Among these features, we find:<\/p>\n<p><strong>&#8211; Union types 2.0<\/strong>: which currently accept new values to be assigned to classes. Previously, it was necessary to do a re-check when several types are assigned to the same class. From now on, this is done automatically.<\/p>\n<p><strong>&#8211; v2 attributes<\/strong>: PHP 8 offers v2 attributes that take the form of metadata (data that describes other data). This metadata allows objects, documents or files to be described and assigned specific characteristics, which can then be added to classes.<\/p>\n<p><strong>&#8211; Named arguments<\/strong>: The peculiarity of these arguments, as their name indicates, is the fact that they are named. In fact, they allow to pass arguments to a function according to the name of the parameter concerned. This avoids the confusion that results when there is a long list of arguments and parameters.<\/p>\n<p><strong>&#8211; The throw expression<\/strong>: The PHP 8 version converts \u201cthrow\u201d from a statement to an expression. The goal is to be able to use it in any position or context where expressions are allowed.<\/p>\n<p><strong>&#8211; Weak Maps<\/strong>: The purpose of weak maps is to improve resource management when manipulating objects. Indeed, the PHP 7.4 version had already found a way to support weak raw references, which are less useful but still occupy space.<\/p>\n<p>With that said, the introduction of the weakmap class makes it possible to create objects that can be easily destroyed and removed when they are no longer useful. This feature improves memory performance.<\/p>\n<p><strong>&#8211; The end comma in the parameter list<\/strong>, including functions, methods and closures, is a new feature added in PHP 8 which has experienced a high demand.<\/p>\n<p><strong>&#8211; \u201cNullsafe\u201d operator<\/strong>: The special part of this feature is the possibility of using a new Nullsafe operator for a call chain. This avoids making conditional checks of null since the operator allows to evaluate the entire string to null and to stop it if one of the operators is evaluated to null.<\/p>\n<p>All the features that were introduced with the new version of PHP allow us to say that this update was a great success. This comes back to the many efficient optimizations and changes that have improved the performance of applications and the writing of better, more robust, accurate, detailed and powerful codes.<\/p>\n<p>Get the PHP 8 version with your <a href=\"https:\/\/www.capconnect.com\/en\/web-hosting\" target=\"_blank\" rel=\"noopener noreferrer\">web hosting<\/a> plan now!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The PHP language has once again been updated. As a matter of fact, the PHP 8 version was launched in 2020 and is currently the most recent version that has&hellip;<\/p>\n","protected":false},"author":3,"featured_media":709,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[210,187],"tags":[242,244,190],"class_list":["post-700","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","category-web-hosting","tag-domain-name","tag-php-8-en","tag-web-hosting"],"_links":{"self":[{"href":"https:\/\/www.capconnect.com\/blog\/wp-json\/wp\/v2\/posts\/700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.capconnect.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.capconnect.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.capconnect.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.capconnect.com\/blog\/wp-json\/wp\/v2\/comments?post=700"}],"version-history":[{"count":0,"href":"https:\/\/www.capconnect.com\/blog\/wp-json\/wp\/v2\/posts\/700\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.capconnect.com\/blog\/wp-json\/wp\/v2\/media\/709"}],"wp:attachment":[{"href":"https:\/\/www.capconnect.com\/blog\/wp-json\/wp\/v2\/media?parent=700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.capconnect.com\/blog\/wp-json\/wp\/v2\/categories?post=700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.capconnect.com\/blog\/wp-json\/wp\/v2\/tags?post=700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}