, ,

What’s New in PHP 7.2 (Improvements, Security, Deprecations)

Posted by

PHP 7.2 was released on November 30th, 2017, and introduced several improvements, security enhancements, and deprecations. Here are some of the key features of PHP 7.2:

Improvements:

  • Object typehint: Prior to PHP 7.2, developers could only typehint for scalar types and arrays, but not for objects. PHP 7.2 introduced the ability to typehint for objects, allowing developers to specify which class or interface an argument should be an instance of.
  • Libsodium Extension: PHP 7.2 includes a new sodium extension, which is a modern cryptography library that provides improved security compared to previous cryptography libraries.
  • Support for Negative String Offsets: In previous versions of PHP, accessing a string with a negative offset would result in an error. However, in PHP 7.2, negative offsets are now supported, and return the character at the corresponding position from the end of the string.

Security Enhancements:

  • Argon2 Password Hashing: PHP 7.2 includes support for the Argon2 password hashing algorithm, which is a modern, memory-hard algorithm that provides improved security compared to previous password hashing algorithms.
  • Improved TLS support: PHP 7.2 includes improved support for TLS connections, including support for TLS 1.3, which provides improved security and performance.
  • Improved random number generation: PHP 7.2 includes improvements to the random number generation functions, making them more secure and predictable.

Deprecations:

  • __autoload() Function: The __autoload() function has been deprecated in favor of the spl_autoload_register() function, which provides more flexibility and control over class loading.
  • create_function() Function: The create_function() function has been deprecated, as it is considered a security risk. Developers should use anonymous functions instead.
  • parse_str() Function without second parameter: In previous versions of PHP, the parse_str() function would automatically create variables in the global scope. This behavior has been deprecated, and developers should use the second parameter to explicitly define the target array.

These are just a few of the key improvements, security enhancements, and deprecations introduced in PHP 7.2. Developers should consult the official documentation for a full list of changes and recommended upgrade practices.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.