可能重复:
如何在 PHP 中将变量名作为字符串获取?
例子:
可以在 PHP 中实现这样的事情吗?
$Age = 43;
output_variable_name_and_value($Age);
/*
outputs:
"The requested variable name is Age and its current value is 43";
*/
//If possible, how would the line marked below with ? ? ? ? be?
function output__variable_name_and_value($input)
{
$var_name = get_name_somehow($input); // ? ? ? ?
echo "The requested variable name is {$var_name}
and its current value is {$input}";
}