What does the code $ {$ key} mean?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.