I can’t access superglobals via variable variables inside a function. Am I the source of the problem or is it one of PHP’s subtleties? And how to bypass it?
print_r(${'_GET'});
works fine
$g_var = '_GET';
print_r(${$g_var});
Gives me a Notice: Undefined variable: _GET
PHP isn’t able to recognize that this is a global variable access:
It compiles
$_GETand${'_GET'}to the same opcode sequence, namely aglobalFETCH_R.${$g_var}on the other hand will result in alocalFETCH_R.This is also mentioned in the docs: