Reputation: 231
from https://www.php.net/manual/en/language.variables.variable.php
this work so cool:
$Z = ARRAY(1, 2, 3);
$H = 'Z';
print_r($$H);
then why this never work:
$Q = 'GLOBALS';
print_r($$Q);
Upvotes: 0
Views: 41
Reputation: 19546
The documentation on variable variables states that it isn't possible to access superglobal variables that way:
Warning Please note that variable variables cannot be used with PHP's Superglobal arrays within functions or class methods. The variable
$this
is also a special variable that cannot be referenced dynamically.
Upvotes: 1