Latest in branch 7.1
7.1.33
Released 24 Oct 2019
(6 years ago)
SoftwarePHP
Version7.1
Status
End of life
Initial release7.1.0
01 Dec 2016
(9 years ago)
Latest release7.1.33
24 Oct 2019
(6 years ago)
End of bug fixes01 Dec 2018
(Ended 7 years ago)
End of security fixes01 Dec 2019
(Ended 6 years ago)
Release noteshttps://www.php.net/ChangeLog-7.php#7.1.33
Source codehttps://github.com/php/php-src/tree/php-7.1.33
Documentationhttps://www.php.net/manual/en/
Downloadhttps://www.php.net/releases/7.1.33
PHP 7.1 ReleasesView full list

What Is New in PHP 7.1

Category Key Changes
New Features Nullable types, Void return type, Iterable pseudo-type, Class constant visibility, Square bracket array destructuring
Improvements Asynchronous signal handling, Catching multiple exception types, Support for keys in list()
Deprecations ext/mcrypt, Several optional parameters moved to the end
Security Reject invalid class names, ext/curl fixes

What new type hints does PHP 7.1 introduce?

PHP 7.1 adds three significant type system enhancements. The iterable pseudo-type provides a way to type-hint arrays or Traversable objects, cleaning up parameter declarations.

Nullable types allow a parameter or return value to accept the specified type or null by prefixing with a question mark. This replaces the common pattern of using docblocks for this purpose.

The void return type explicitly declares that a function does not return any value. Attempting to return a value from a void function triggers a fatal error, making the code's intent clearer.

How does exception handling improve in this version?

You can now catch multiple exception types in a single block using the pipe character. This reduces code duplication when the same handling logic applies to different exception classes.

try {
    // Some code that may throw
} catch (FirstException | SecondException $e) {
    // Handle both exceptions
}

In practice, this is cleaner than having multiple catch blocks with the same body or creating deep inheritance hierarchies just for grouping exceptions.

What changes were made to class constants?

Class constants now support visibility modifiers (public, protected, private), bringing them in line with properties and methods. Previously, all constants were implicitly public.

class MyClass {
    public const PUBLIC_CONST = 'value';
    protected const PROTECTED_CONST = 'value';
    private const PRIVATE_CONST = 'value';
}

This matters because it allows for better encapsulation. You can now hide implementation details by making constants private or protected.

How does list() work differently now?

The list() language construct now supports explicit key specification. You can destructure arrays with non-integer or non-sequential keys, which wasn't possible before.

$data = ['id' => 1, 'name' => 'Alice'];
list('id' => $id, 'name' => $name) = $data;

You can also use shorthand array syntax within list() for the same effect. This is particularly useful when working with associative arrays returned from database queries or APIs.

What got deprecated in PHP 7.1?

The ext/mcrypt extension is now deprecated. If you're still using it for encryption, you should migrate to OpenSSL, which is more actively maintained and secure.

Several optional parameters were moved to the end of parameter lists in various functions. This affects functions like openssl_random_pseudo_bytes() and debug_backtrace(). The old parameter order still works but generates deprecation notices.

Always check your error logs after upgrading to identify these deprecations. They won't break your application immediately but will need addressing before the next major version.

FAQ

Can I use nullable types with all type hints?
Yes, nullable types work with any type declaration except void. You prefix the type with a question mark, like ?string or ?int, to indicate it can also accept null.

What happens if I return a value from a void function?
PHP 7.1 will throw a fatal error if you try to return any value from a function declared with a void return type. This includes returning null explicitly.

Is the mcrypt extension removed in PHP 7.1?
No, it's only deprecated. The extension still functions but generates deprecation warnings. It was completely removed in PHP 7.2, so you should replace it immediately.

Can I use iterable in return type declarations?
Absolutely. The iterable type can be used for both parameter type hints and return type declarations, making your interface contracts more precise when working with arrays or traversable objects.

How do I handle the changed parameter order deprecations?
You need to update your function calls to use the new parameter order. The deprecation notice will tell you which function is affected. In most cases, you'll need to move optional parameters to the end of your function calls.

Releases In Branch 7.1

VersionRelease date
7.1.3324 Oct 2019
(6 years ago)
7.1.3229 Aug 2019
(6 years ago)
7.1.3101 Aug 2019
(6 years ago)
7.1.3030 May 2019
(7 years ago)
7.1.2802 May 2019
(7 years ago)
7.1.2902 May 2019
(7 years ago)
7.1.2707 Mar 2019
(7 years ago)
7.1.2610 Jan 2019
(7 years ago)
7.1.2506 Dec 2018
(7 years ago)
7.1.2408 Nov 2018
(7 years ago)
7.1.2311 Oct 2018
(7 years ago)
7.1.2213 Sep 2018
(7 years ago)
7.1.2113 Sep 2018
(7 years ago)
7.1.2016 Aug 2018
(7 years ago)
7.1.1921 Jun 2018
(7 years ago)
7.1.1824 May 2018
(8 years ago)
7.1.1726 Apr 2018
(8 years ago)
7.1.1629 Mar 2018
(8 years ago)
7.1.1501 Mar 2018
(8 years ago)
7.1.1401 Feb 2018
(8 years ago)
7.1.1304 Jan 2018
(8 years ago)
7.1.1223 Nov 2017
(8 years ago)
7.1.1126 Oct 2017
(8 years ago)
7.1.1028 Sep 2017
(8 years ago)
7.1.931 Aug 2017
(8 years ago)
7.1.803 Aug 2017
(8 years ago)
7.1.706 Jul 2017
(8 years ago)
7.1.608 Jun 2017
(9 years ago)
7.1.511 May 2017
(9 years ago)
7.1.413 Apr 2017
(9 years ago)
7.1.316 Mar 2017
(9 years ago)
7.1.216 Feb 2017
(9 years ago)
7.1.119 Jan 2017
(9 years ago)
7.1.001 Dec 2016
(9 years ago)