Latest in branch 7.4
7.4.33
Released 03 Nov 2022
(3 years ago)
SoftwarePHP
Version7.4
Status
End of life
Initial release7.4.0
28 Nov 2019
(6 years ago)
Latest release7.4.33
03 Nov 2022
(3 years ago)
End of bug fixes28 Nov 2021
(Ended 4 years, 6 months ago)
End of security fixes28 Nov 2022
(Ended 3 years, 6 months ago)
Release noteshttps://www.php.net/ChangeLog-7.php#7.4.33
Source codehttps://github.com/php/php-src/tree/php-7.4.33
Documentationhttps://www.php.net/manual/en/
Downloadhttps://www.php.net/releases/7.4.33
PHP 7.4 ReleasesView full list

What Is New in PHP 7.4

Category Key Changes
New Features Typed Properties, Arrow Functions, Spread Operator in Arrays, Preloading
Improvements FFI Extension, Weak References, Custom Object Serialization
Deprecations Left-associative Ternary Operator, Nested Ternary without Parentheses, Curly Braces for Array/String Access
Other Changes Password Hashing Registry, Numeric Literal Separator, mb_str_split function

What are the major new language features in PHP 7.4?

PHP 7.4 introduces several syntax enhancements that make code more expressive and type-safe. Typed properties allow class properties to declare their type, which catches type errors early. Arrow functions provide a cleaner syntax for short closures, reducing boilerplate code.

The spread operator (...) now works for array literals, making array merging more intuitive. This is similar to how it works in argument unpacking, but for arrays.

Example: Typed Properties

class User {
    public int $id;
    public string $name;
    public ?Profile $profile; // Nullable type
}

How does preloading improve performance?

Preloading is a significant performance feature for OPcache. It allows the server to load a set of PHP files into memory at startup, making them permanently available for all subsequent requests.

This eliminates the need to compile these scripts on every request, which reduces overhead and improves response times. In practice, this benefits frameworks that use a large codebase, as their core classes are always ready to execute.

What deprecations should developers watch out for?

Several old behaviors are now deprecated and will generate warnings. Using curly braces for array and string offset access (e.g., $array{0}) is deprecated in favor of square brackets.

The nested ternary operator without explicit parentheses and the left-associative ternary operator are also deprecated due to confusion in evaluation order. These changes encourage clearer, less ambiguous code.

Deprecated Syntax

$a = $b[0];   // Correct
$a = $b{0};   // Deprecated

$c = $a ? $b : $c ? $d : $e; // Deprecated (ambiguous)
$c = ($a ? $b : $c) ? $d : $e; // Explicit

What are the new core extensions and improvements?

The Foreign Function Interface (FFI) extension is now available, allowing PHP to call functions from shared libraries and interact with C data structures. This is powerful for high-performance tasks or integrating with low-level libraries.

Weak References allow the programmer to retain a reference to an object that does not prevent the object from being destroyed by the garbage collector. This is useful for implementing caches.

FAQ

Is the spread operator for arrays the same as argument unpacking?
Yes, the syntax is identical (...), but it is now used within array literals to merge arrays, e.g., $newArray = [...$array1, ...$array2];.

Can I use typed properties with any type?
Yes, all supported types work: bool, int, float, string, array, object, iterable, self, parent, and nullable types with ?.

What happens if I assign a wrong type to a typed property?
A TypeError is thrown immediately, which helps catch bugs much earlier in development compared to untyped code.

Is the FFI extension enabled by default?
No, the FFI extension is not enabled by default. It must be explicitly enabled via the ffi.enable directive in your php.ini configuration file.

Are there any new functions added?
Yes, mb_str_split() is a new function that splits a multibyte string into an array, similar to str_split() but for multibyte encodings.

Releases In Branch 7.4

VersionRelease date
7.4.3303 Nov 2022
(3 years ago)
7.4.3229 Sep 2022
(3 years ago)
7.4.3009 Jun 2022
(4 years ago)
7.4.2914 Apr 2022
(4 years ago)
7.4.2817 Feb 2022
(4 years ago)
7.4.2716 Dec 2021
(4 years ago)
7.4.2618 Nov 2021
(4 years ago)
7.4.2521 Oct 2021
(4 years ago)
7.4.2423 Sep 2021
(4 years ago)
7.4.2326 Aug 2021
(4 years ago)
7.4.2229 Jul 2021
(4 years ago)
7.4.2101 Jul 2021
(4 years ago)
7.4.2003 Jun 2021
(5 years ago)
7.4.1906 May 2021
(5 years ago)
7.4.1829 Apr 2021
(5 years ago)
7.4.1604 Mar 2021
(5 years ago)
7.4.1504 Feb 2021
(5 years ago)
7.4.1407 Jan 2021
(5 years ago)
7.4.1326 Nov 2020
(5 years ago)
7.4.1229 Oct 2020
(5 years ago)
7.4.1101 Oct 2020
(5 years ago)
7.4.1003 Sep 2020
(5 years ago)
7.4.906 Aug 2020
(5 years ago)
7.4.809 Jul 2020
(5 years ago)
7.4.711 Jun 2020
(5 years ago)
7.4.614 May 2020
(6 years ago)
7.4.516 Apr 2020
(6 years ago)
7.4.419 Mar 2020
(6 years ago)
7.4.320 Feb 2020
(6 years ago)
7.4.223 Jan 2020
(6 years ago)
7.4.118 Dec 2019
(6 years ago)
7.4.028 Nov 2019
(6 years ago)