{"id":7000,"date":"2017-12-20T17:03:14","date_gmt":"2017-12-20T16:03:14","guid":{"rendered":"https:\/\/www.combell.com\/en\/blog\/?p=7000"},"modified":"2021-07-12T09:25:38","modified_gmt":"2021-07-12T07:25:38","slug":"what-is-new-php-7-2","status":"publish","type":"post","link":"https:\/\/www.combell.com\/en\/blog\/what-is-new-php-7-2\/","title":{"rendered":"What is new in PHP 7.2?"},"content":{"rendered":"<p>On 30 November 2017, <a href=\"http:\/\/php.net\/archive\/2017.php#id2017-11-30-1\" target=\"_blank\" rel=\"noopener\">the PHP community announced the release of PHP 7.2<\/a>. More specifically, this is the second feature update to the PHP 7 series.<\/p>\n<h2><strong>Building on the achievements of PHP 7<\/strong><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-14592\" title=\"PHP7\" src=\"https:\/\/www.combell.com\/nl\/blog\/files\/2017\/12\/PHP7.png\" alt=\"PHP7\" width=\"120\" height=\"169\" \/>PHP 7 was released at the end of 2015 and marked a new era for the programming language and the associated community, which have gone through some major changes over the last few years.<\/p>\n<p>PHP is a very accessible language, which is sometimes discredited by language purists in the development world. The reality, however, is that more than 83% of all websites on the Internet are written in PHP. And popular frameworks such as WordPress, Drupal and Magento only contribute to the success of the PHP ecosystem.<\/p>\n<p>Major investments have been made to significantly improve the performance of PHP 7. Great efforts have also been made for a better type hinting, and many old extensions are no longer supported.<\/p>\n<p><a href=\"http:\/\/php.net\/supported-versions.php\" target=\"_blank\" rel=\"noopener\">The release timeline<\/a> shows that feature updates are released on a yearly basis. So, this year, after the release of PHP 7.1 in 2016, we got PHP 7.2 as an early Christmas gift.<\/p>\n<h2><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14593 aligncenter\" src=\"https:\/\/www.combell.com\/nl\/blog\/files\/2017\/12\/Kalender-PHP-7.2-release.png\" alt=\"Kalender PHP 7.2 release\" width=\"965\" height=\"244\" \/><br \/>\n<strong>PHP 7.2 is essentially a security feature release<\/strong><\/h2>\n<p>Except for some minor improvements to the language itself, one observes that most <a href=\"http:\/\/php.net\/releases\/7_2_0.php\" target=\"_blank\" rel=\"noopener\">new features<\/a> are security related.<\/p>\n<ul>\n<li>Announcement of the new <a href=\"https:\/\/wiki.php.net\/rfc\/argon2_password_hash\" target=\"_blank\" rel=\"noopener\">Argon2 Password Hashing algorithm in the PHP core<\/a><\/li>\n<li><a href=\"https:\/\/wiki.php.net\/rfc\/mcrypt-viking-funeral\" target=\"_blank\" rel=\"noopener\">Removal of the mcrypt<\/a> extension from the PHP core<\/li>\n<li>Implementation of the Sodium extension in the PHP core<\/li>\n<li>Improvement of the minimum TLS version constants<\/li>\n<\/ul>\n<h2><strong>Argon2 Password Hashing<\/strong><\/h2>\n<p>Until recently, bcrypt was the best choice to <a href=\"http:\/\/php.net\/manual\/en\/function.password-hash.php\" target=\"_blank\" rel=\"noopener\">hash passwords in PHP<\/a>. With the release of PHP 7.2, developers now have the opportunity to use <a href=\"https:\/\/wiki.php.net\/rfc\/argon2_password_hash\" target=\"_blank\" rel=\"noopener\">Argon2<\/a>, an alternative password hashing algorithm.<\/p>\n<p>Argon2 came first in the <a href=\"https:\/\/password-hashing.net\/\" target=\"_blank\" rel=\"noopener\">Password Hashing Competition<\/a> and is considered more secure than bcrypt thanks to the fact that, in addition to a \u201ctime cost\u201d, there is also a \u201cmemory cost\u201d.<\/p>\n<p>This means that the algorithm will make it harder for hackers to crack passwords using brute force attacks. The \u201ctime cost\u201d is usually avoided by unleashing powerful GPU-based computing power on the password.<\/p>\n<p>The extra \u201cmemory cost\u201d ensures that these machines suddenly require a proportional amount of RAM to be able to guess the password with a brute force attack.<\/p>\n<p>Another benefit of Argon2 is that it also allows you to define the number of parallel threads used to calculate the complexity of the password hashing algorithm.<\/p>\n<h2><strong>Mcrypt is gone<\/strong><\/h2>\n<p><a href=\"http:\/\/php.net\/manual\/en\/intro.mcrypt.php\" target=\"_blank\" rel=\"noopener\">Mcrypt<\/a> is a popular PHP cryptography extension. Unfortunately, the mcrypt library on which this extension depends has not been updated since 2007.<\/p>\n<p>The library has several bugs and patches that have not been fixed for quite a long time. In PHP 7.1, this extension was already deprecated. <a href=\"https:\/\/wiki.php.net\/rfc\/mcrypt-viking-funeral\" target=\"_blank\" rel=\"noopener\">In 7.2, mcrypt was removed from the PHP core<\/a> and <a href=\"http:\/\/pecl.php.net\/package\/mcrypt\" target=\"_blank\" rel=\"noopener\">moved to the Pecl repository<\/a>.<\/p>\n<p>Instead of Mcrypt, developers can now use <a href=\"http:\/\/php.net\/openssl\" target=\"_blank\" rel=\"noopener\">OpenSSL<\/a> and the new Sodium extension.<\/p>\n<h2><strong>Sodium as a competitor to OpenSSL<\/strong><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14597 alignright\" title=\"Libsodium in PHP 7.2\" src=\"https:\/\/www.combell.com\/nl\/blog\/files\/2017\/12\/libsodium.png\" alt=\"Libsodium in PHP 7.2\" width=\"250\" height=\"70\" \/>OpenSSL is the most popular cryptography library, but it has both pros and cons. In the spirit of healthy competition, PHP 7.2 provides <a href=\"https:\/\/wiki.php.net\/rfc\/libsodium\" target=\"_blank\" rel=\"noopener\">an alternative cryptography library: Sodium<\/a>.<\/p>\n<p>A libsodium implementation has long been available in PHP, <a href=\"http:\/\/pecl.php.net\/package\/libsodium\" target=\"_blank\" rel=\"noopener\">via Pecl<\/a>. Promoting this extension required a namespace change to conform to the PHP coding standards: in PECL, the \u201c\\Sodium\u201d namespace was used to call associated features.<\/p>\n<p>In PHP 7.2, these features will be included in the root namespace and <a href=\"http:\/\/php.net\/manual\/en\/ref.sodium.php\" target=\"_blank\" rel=\"noopener\">re-prefixed \u201csodium\u201d<\/a>.<\/p>\n<h2><strong>The improvement of TLS version constants<\/strong><\/h2>\n<p>Until recently, \u201cssl\u201d was the standard stream wrapper when an encrypted connection was established from PHP. The developers of PHP 7.2 decided to make \u201ctls\u201d default and \u201cssl\u201d an alias.<\/p>\n<p>They also decided to <a href=\"https:\/\/wiki.php.net\/rfc\/improved-tls-constants\" target=\"_blank\" rel=\"noopener\">be more rigorous<\/a> about supported TLS versions. Clients with only TLS 1.0 enabled will no longer be supported.<\/p>\n<p>In the past, an attempt had already been made for this, but <a href=\"https:\/\/wiki.php.net\/rfc\/improved-tls-defaults\" target=\"_blank\" rel=\"noopener\">back then, the decision was postponed to maintain compatibility with PHP 5.6<\/a>. The fact that PHP 7.2 is part of a new \u201cmajor release\u201d allows for such a \u201cbackwards compatibility break\u201d.<\/p>\n<h2><strong>Language-related features<\/strong><\/h2>\n<p>The language-related features are not particularly remarkable and are mainly corrections of previous errors:<\/p>\n<ul>\n<li><a href=\"https:\/\/wiki.php.net\/rfc\/convert_numeric_keys_in_object_array_casts\" target=\"_blank\" rel=\"noopener\">Correct conversion of numeric keys when casting objects to arrays and vice-versa<\/a><\/li>\n<li><a href=\"https:\/\/wiki.php.net\/rfc\/counting_non_countables\" target=\"_blank\" rel=\"noopener\">Returning correct results when calling a non-countable object via \u201ccount\u201d<\/a><\/li>\n<\/ul>\n<p>The only noteworthy language feature in PHP 7.2 is <a href=\"https:\/\/wiki.php.net\/rfc\/object-typehint\" target=\"_blank\" rel=\"noopener\">the availability of the \u201cobject typehint\u201d<\/a>, which allows to accept and return generic objects in functions and methods. This way, it is no longer necessary to use specific class names.<\/p>\n<h2><strong>From now on, PHP 7.2 is also available on Combell\u2019s shared hosting platform<\/strong><\/h2>\n<p>PHP 7.2 was released on 30 November 2017. On the very same day, we announced that this version was also supported on our shared hosting platform.<\/p>\n<p><a href=\"https:\/\/twitter.com\/combell\/status\/936253455265648640\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14595 size-full aligncenter\" title=\"PHP 7.2 aankondiging twitter\" src=\"https:\/\/www.combell.com\/nl\/blog\/files\/2017\/12\/PHP-7.2-aankondiging-twitter.png\" alt=\"PHP 7.2 aankondiging twitter\" width=\"658\" height=\"320\" \/><\/a><\/p>\n<p>As of now, you can thus use all the new features. With new web hosting packages, you can immediately pick this version. And with existing packages, you can switch versions on the fly in <a href=\"http:\/\/my.combell.com\" target=\"_blank\" rel=\"noopener\">My Combell<\/a>.<\/p>\n<p style=\"text-align: center;\"><a class=\"cta_button\" href=\"http:\/\/my.combell.com\" target=\"_blank\" rel=\"noopener\">Go to My Combell<\/a><\/p>\n<p>This new release also includes many <a href=\"http:\/\/php.net\/ChangeLog-7.php#7.2.0\" target=\"_blank\" rel=\"noopener\">bug fixes and internal improvements<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On 30 November 2017, the PHP community announced the release of PHP 7.2. More specifically, this is the second feature update to the PHP 7 series. Building on the achievements...<\/p>\n","protected":false},"author":25,"featured_media":7001,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[66,67,75,72],"tags":[252,255],"acf":[],"uagb_featured_image_src":{"full":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog.jpg",820,290,false],"thumbnail":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog-50x50.jpg",50,50,true],"medium":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog-300x106.jpg",300,106,true],"medium_large":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog-768x272.jpg",768,272,true],"large":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog.jpg",820,290,false],"1536x1536":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog.jpg",820,290,false],"2048x2048":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog.jpg",820,290,false],"post-featured":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog-820x290.jpg",820,290,true],"post-featured-opt":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog-750x256.jpg",750,256,true],"post-featured-opt-md":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog-820x290.jpg",820,290,true],"post-featured-opt-sm":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog-485x165.jpg",485,165,true],"post-featured-opt-xs":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog-375x128.jpg",375,128,true],"post-most-popular":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog-50x50.jpg",50,50,true],"post-author":["https:\/\/www.combell.com\/en\/blog\/files\/2017\/12\/PHP-72-blog-60x60.jpg",60,60,true]},"uagb_author_info":{"display_name":"thijsferyn","author_link":"https:\/\/www.combell.com\/en\/blog\/author\/thijsferyn\/"},"uagb_comment_info":6,"uagb_excerpt":"On 30 November 2017, the PHP community announced the release of PHP 7.2. More specifically, this is the second feature update to the PHP 7 series. Building on the achievements...","_links":{"self":[{"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/posts\/7000"}],"collection":[{"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/comments?post=7000"}],"version-history":[{"count":4,"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/posts\/7000\/revisions"}],"predecessor-version":[{"id":7006,"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/posts\/7000\/revisions\/7006"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/media\/7001"}],"wp:attachment":[{"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/media?parent=7000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/categories?post=7000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.combell.com\/en\/blog\/wp-json\/wp\/v2\/tags?post=7000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}