Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

$GLOBALS Assignement

It is not possible to assign the $GLOBALS variable anymore. The individual values may still be assigned directly.

PHP code

<?php

$GLOBALS['a']  = 1;

$b = &$GLOBALS;
$b = array();

print_r($GLOBALS);

?>

Before

Array
(
)

After

PHP Fatal error:  Cannot acquire reference to $GLOBALS

PHP version change

This behavior changed in 8.1.

Error Messages

Analyzer

© 2023-2026, Damien Seguy - Exakat