PHP 7.4 Released
PHP 7.4 Released

PHP 7.4 Released
PHP 7.4 has finally arrived!
Preloading
Preloading is run by a specific php.ini directive: opache.preload.This has the PHP script compiler and executes when the server starts up. It can also be used to preload more files and choose to either include or compile them.
However, if the source of the preloaded files is ever changed, the server must be restarted. The preloaded files also remain cached in the OPCache memory forever.
Spread Operator in Array Expressions
PHP began supporting argument unpacking (spread operator) in PHP 5.6 but now, with 7.4, we are able to use this feature with an array expression.
Argument unpacking is a syntax for unpacking arrays and traversables into argument lists. And, in order to do so, it only needs to be prepended by … (3 dots.)
$num1 = [1, 2, 3];
$num2 = [...$num1]; // [1, 2, 3]
$num3 = [0, ...$num1]; // [0, 1, 2, 3]
$num4 = array(...$num1, ...$num2, 111); // [1, 2, 3, 1, 2, 3, 111]
$num5 = [...$num1, ...$num1]; // [1, 2, 3, 1, 2, 3]
No longer need array_merge
$array = [‘banana, ‘orange’];
$array[2] = ‘orange’;
$array[1] = ‘apple’; //shifting
var_dump($array);
// prints
array(3) {
[0]=>
string(6) "banana"
[1]=>
string(5) "apple"
[2]=>
string(6) "orange"
}
Typed Properties 2.0
PHP 7.4 can now support the following type list:
bool, int, float, string, array, object, iterable, self, parent
any class or interface name
?type // where "type" may be any of the above
Example php 7.4 class with type-safety:
class User {
public int $id;
public string $name;
public function __construct(int $id, string $name) {
$this->id = $id;
$this->name = $name;
}
}