You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempting to access an array key which has not been defined is the same as accessing any other undefined variable: an E_WARNING-level error message (E_NOTICE-level prior to PHP 8.0.0) will be issued, and the result will be null.
but this isn't actually true when assigning null; [$x, $y] = null; does not raise a notice or warning (eval). Same goes for destructuring with an associative array (eval). This seems to be specific to null (e.g. [$x, $y] = []; raises a warning: eval) and to destructuring assignment (e.g. null[0] raises a warning: eval).
Not sure if this is a bug or a documentation issue, but either there should be a warning or this special case should be documented.
The text was updated successfully, but these errors were encountered:
https://www.php.net/manual/en/language.types.array.php#language.types.array.syntax.destructuring says
but this isn't actually true when assigning null;
[$x, $y] = null;
does not raise a notice or warning (eval). Same goes for destructuring with an associative array (eval). This seems to be specific to null (e.g.[$x, $y] = [];
raises a warning: eval) and to destructuring assignment (e.g.null[0]
raises a warning: eval).Not sure if this is a bug or a documentation issue, but either there should be a warning or this special case should be documented.
The text was updated successfully, but these errors were encountered: