Appending To $GLOBALS
$GLOBALS is not a regular array: each of its entries is really a reference to a variable in the global scope, identified by its name. Appending to it with the empty-bracket operator, which would normally pick the next integer key, has no matching global variable to bind to. Before PHP 8.1, this meaningless operation was silently tolerated, and created a global variable literally named “0”. As of PHP 8.1, $GLOBALS is treated more strictly by the compiler, and this and several other previously-tolerated usages now raise a compile-time error instead.
PHP code
<?php
$GLOBALS[] = 'value';
?>
Before
After
PHP Fatal error: Cannot append to $GLOBALS
PHP version change
This behavior changed in 8.1.