获取函数内部的赋值变量


Get assigned variable inside a function

是否可以在函数内部获取函数所分配的变量名??

示例:

$firstName = greet();
$John = greet();
function greet()
{
$name = /* things to get the "firstName" without the $ */;
echo "Hello $name!";
}

这个应该打印:

你好,firstName!

你好,约翰!

我想做这样的事,有可能吗??

否。不是以任何理智可行的方式
首先也没有合理的理由依赖这些信息。

如果你真的想做这样的事情,你可以写一个名为Variable的数据结构来存储变量的名称。但不知怎么的,我怀疑你在OOP方面会有太多运气,因为你问了这个问题。。。