Back Button PHP

What's New in PHP 7.1

Though not as flashy as the long-in-development 7.0 release, PHP 7.1 nonetheless brings with it a number of useful features, ranging from short array destructuring, to negative string offsets, to improved return types. Come along, as we review what's new in PHP!
5 episodes
19:57 mins
Start Series
  • Episode 1 Run Time 3:09

    Before we can toy around with the new additions to PHP 7.1, we must first install it. In the past, this was always a pain in the neck to accomplish; however, these days, we only need to pull in Rasmus' Vagrant image to get up and running as quickly as possible.

  • Episode 2 Run Time 4:30

    First up, we have symmetric array destructuring: an incredibly confusing term for a simple concept: we can now use the short array syntax to translate (or destructure) any array - both indexed and associative - into a list of variables.

  • Episode 3 Run Time 6:18

    Nullable and void types are both new to PHP 7.1. Should you desire to, you may now mark a typehint or return type as being nullable, simply by prefixing it with a question mark. This indicates that you expect either the given type, or null. Additionally, the ability to specify a void return type is now available.

  • Episode 4 Run Time 2:11

    Often, you'll find yourself catching and responding to multiple exception types with the exact same logic. In PHP 7.1, however, you may now remove this duplication by separating each exception type with a pipe (catch (ChargeFailed | InsufficientFunds $e)).

  • Episode 5 Run Time 3:49

    New to PHP 7.1 is a new iterable pseudo-type. If you're currently type-hinting array all over the place, think about it: would you be that upset if the user instead passed an object that can be iterated over? Of course not. This new pseudo-type solves that!