简体   繁体   中英

Can I do something like this: $_REQUEST[$_REQUEST['field_name']]?

Can I do something like this?

$captcha_results = $_REQUEST[$_REQUEST['field_name']];

I am interested in it, because I try to find out where I've made a mistake. Thank you in advance.

Yes, of course. The one you've just asked is one of variable variables. You can learn more the PHP variables here:

  1. PHP Variable Basics
  2. Variable in Variable

For example, you have $var containing value of foobar . You can use the value for other references (in my case, as an index of an array), as shown below.

$var = 'foobar';
$array['foobar'] = 'bar';

echo $array[$var];

This will output bar as a result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM