What does the code $ {$ key} mean?
$globals = array($_REQUEST, $_SESSION, $_SERVER, $_FILES);foreach($globals as $global){ foreach(array_keys($global) as $key){ unset(${$key}); }}
Unset ($ {$ key}); how is this line of code executed successfully,
Reply to discussion (solution)
See the manual for variable variables.
See the manual for variable variables.
I also read the manual and I don't know when to use it. the demo I made is not executed successfully. The example is as follows:
$globals = array(array('param1'=>'PRC','param'=>'USA'));foreach($globals as $global){ foreach(array_keys($global) as $key){ unset(${$key}); }}
The example you provided does not make much sense. this is the usual usage.
$a = 1;$b = 2;$c = 3;foreach(array('a', 'b', 'c') as $k) echo ${$k};123
The example you provided does not make much sense. this is the usual usage.
$a = 1;$b = 2;$c = 3;foreach(array('a', 'b', 'c') as $k) echo ${$k};123
Okay. thank you.