PHP 7.2 With Built-in Libsodium |
Written by Kay Ewbank | |||
Wednesday, 06 December 2017 | |||
There's a new release of PHP that adds several features, including a new sodium extension making PHP the first programming language to adopt modern cryptography in its standard library. The inclusion of the Libsodium library in the core means developers no longer have to use PECL to access the library, or to rely on openssl. Libsodium is a cross-platform and cross-languages library for encryption, decryption, signatures, and password hashing. Another security improvement adds support for Argon 2 to password functions as a secure alternative to Bcrypt. The new version of PHP, 7.2.0 has other improvements, starting with object typehints.PHP 5 added the ability to specify argument types in a function’s declaration to say what type of argument is expected to be passed. These are known as type hints. PHP 7.2 has extended this to let you use the object data type for type hints, meaning you can declare a generic object as an argument of a function or method. A second improvement is to the handling of key/value pairs. PHP uses this data type for arrays and objects, and stores both internally using hash tables. However, the two have different restrictions on what kinds of keys they can have, leading to the possibility that if the underlying hash tables are modified directly, arrays and objects can exist with an invalid internal state. The new version converts the keys of array or object hash tables as appropriate, converting numeric string property names in objects to integer array keys, and vice-versa. This will mean there will be no inaccessible properties. Non-countable objects are now better handled. In previous versions, if you called count() on a scalar or object that doesn't implement the Countable interface, the value 1 would be returned, potentially hiding an error. The new release returns a warning if count() is called with a parameter that is a scalar, null, or an object that doesn't implement Countable. Hash Content is another area to have received attention. While objects are the preferred structure for wrapping internal data, the hash extension is an alternative. In this version, the opaque resource is converted to an opaque object, meaning that existing code should continue to function.
More InformationRelated ArticlesPHP Variables and Expressions for Complete Beginners Object-oriented HTML Generation In PHP Peachpie Open Source PHP to .NET Compiler PHP Gets A Formal Specification The Next Version Of PHP And The Status Of PHPng PHP Next Generation Project Announced The Reason For The Weird PHP Function Names
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Wednesday, 06 December 2017 ) |