You won’t be able to initialize array from falsy values any more this include: only false values and nothing else.
PHP 8.1 will continue to allow autovivification from undefined
variable and null
, but in every other case an error message will be shown:
Cannot use a scalar value as an array
Allowing autovivification on null
can be a sign of a buggy code, but it is less of a problem than false
. In PHP, null
and undefined are very similar and often treated the same way, e.g. isset()
and ??
.
Appending array keys to a variable of type false will display a deprecation notice like:
Deprecated: Automatic conversion of false to array is deprecated in XXX
In PHP 9.0, this will throw a fatal error, the same as for other scalar types.
More about PHP 8.1
Read about all PHP 8.1 features and changes in here.