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.

phplogo

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.

 

 phplogo

More Information

PHP Website

Related Articles

What PHP Does

PHP Variables and Expressions for Complete Beginners

Object-oriented HTML Generation In PHP

Peachpie Open Source PHP to .NET Compiler

PHP 5.6 Released

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       

Zend Optimizer+ For PHP?

 

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.

 

Banner


Highlights Of The Europe 2024 PostgreSQL Conference
22/11/2024

This year's premium conference for PostgreSQL took place in Athens, Greece between October 22-25. The nice Athenian weather and cultural aspect aside, the conference was a big hit too.



Personal Picks For Holiday Gifts
29/11/2024

It's Black Friday, the traditional day to indulge in online shopping. Not every item that is included in my selection of gifts is subject to a promotional offer, but where they aren't you might be poi [ ... ]


More News

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Wednesday, 06 December 2017 )