【发布时间】:2012-06-19 20:26:20
【问题描述】:
例子:
这样的事情可以在 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}";
}
【问题讨论】:
-
请确保您的代码有效
-
从接受的答案到重复问题:“要清楚,在 PHP 中没有好的方法可以做到这一点,这可能是因为你不应该这样做。可能有更好的做你想做的事的方法。”