您正在查看一个变量 variable。例如
// original variable named 'foo'
$foo = "bar";
// reference $foo dynamically by evaluating $x
$x = "foo";
echo $$x; // "bar";
echo ${$x}; // "bar" as well but the {} allows you to perform concatenation
// different version of {} to show a more "complex" operation
$y = "fo";
$z = "o";
echo ${$y . $z}; // "bar" also ("fo" . "o" = "foo")
要显示一个更接近您的问题的示例:
$foo = "foo";
$bar = "bar";
$baz = "baz";
$ary = array('foo' => 'FOO','bar' => 'BAR','baz' => 'BAZ');
foreach ($ary as $key => $value){
$$key = $value;
}
// end result is:
// $foo = "FOO";
// $bar = "BAR";
// $baz = "BAZ";