PHP features

Why Use PHP for Your Project? Top 7 Newly Added Features

11 May 2017 - 2 min read

Introduced more than 20 years ago for the first time, PHP has become one of the most imperative server-side languages that still rules the world of computer science and web development. Throughout the years it has evolved tremendously, proving that PHP isn’t going to die out any time soon. According to statistics provided by w3techs, 82.6% of websites are powered by PHP, some of which are the biggest and most popular platforms such as Facebook, Messenger, Twitter, Baidu and so on. The programming language has been released in 7 different versions so far, with the primary goal to optimize its performance and ease of use; extend the abundance of available frameworks; improve data security with the help of third-party applications and enhance its cross-platform compatibility. In order to understand how exactly it has progressed, let’s take a closer look at the latest improvements and see what are the new features that have been launched with the latest version.

PHP features

  • Symmetric Array Destructuring

Thanks to this feature, programmers can now access a number of elements using square bracket syntax instead of a list function. Thus, the symmetric array destructuring allows them to use shorthanded array syntax in order to destruct or translate both indexed and associative arrays into a list of variables quickly and more easily than before.

  • Nullable Types

The 7.1. version also makes it possible for achieving clearer code and more efficient error handling with the help of its nullable types feature. This one adds a leading question mark which allows developers to indicate type declarations for parameters and return values as nullable. In other words, null can be easily returned from a function.

  • Iterable Pseudo-type

PHP features

Knowing exactly what sort of data programmers get definitely reduces the number of errors and makes it easier to deal with. And this is one of the advantages of using iterable pseudo-type when developing with PHP. Notably, the new pseudo-type is similar to callable. The main idea is that both arrays and object implementing Traversable interface can be accepted.

  • Void Return Type

Essentially, by using a void function coders are enabled to write functions, without expecting it to return any value. And instead of delivering a result, the void return type requires omitting the return type and underlines that a given function performs an action. In this case, NULL is not a valid return value.

  • Class Constant Visibility Modifiers

Another enhancement is the ability to specify the visibility of class constants across the project.

  • Multi Catch Exception Handling

With the introduction of this new feature, debugging has become slightly easier to do. Programmers are now enabled to grab multiple errors, catch syntax by adding numerous catchers or specify multiple exceptions per catch block using (/).

  • Support For Keys In list()

PHP features

The positive outcome of this functional addition? Ability to define the keys in list() or when using new shorthand ([]) syntax.

Apart from the features, there are couple of new functions and constants have been added as well. Some of them include:

  • curl_multi_errno()
  • curl_share_strerror()
  • session_create_id()
  • CURL_PUSH_OK
  • IMAGETYPE_WEBP
  • JSON_UNESCAPED_LINE_TERMINATORS
  • LDAP_OPT_X_TLS_CRL_ALL

In conclusion, its instant ease of use and the new set of features, constants and functions, are just a few of the reasons why developers will continue to use PHP for a variety of projects. As the programming language of choice for various applications, by all means, it seems to be able to retain its popularity for a long time to come.

References:
http://php.net/manual/en/migration71.constants.php [accessed: 11 May, 2017]
http://php.net/manual/en/migration71.changed-functions.php [accessed: 11 May, 2017]