No Dynamic Global Variables

In PHP 5.6, dynamic global variables were possible. This means that a variable, whose name is stored in another variable, could be dynamically used with the global keyword.

These notations are now dropped, except for with the ```` operator.

PHP code

<?php

// Valid in all PHP versions
global $normalGlobal;

// Forbidden in PHP 7
global $$variable->global ;

// Tolerated in PHP 7
global $\{$variable->global\};

?>

Before

1

After

PHP Parse error:  syntax error, unexpected token "->", expecting "," or ";" in /codes/globalDynamicVariable.php on line 7

Parse error: syntax error, unexpected token "->", expecting "," or ";" in /codes/globalDynamicVariable.php on line 7

PHP version change

This behavior changed in 5.6