Php 获取令牌';s名称与反射API

Php 获取令牌';s名称与反射API,php,reflection,Php,Reflection,我想找到通过augment传递到函数中的令牌的名称 class Norm { const STR_NORM = 0; const INT_NORM = 0; } function foo($Arg1, $Arg2 = NULL) { getConstName($Arg1); # Should Return STR_NORM; return $Arg1, $Arg2; } echo foo(Norm::STR_NORM); 有没有办法通过实现getConstN

我想找到通过augment传递到函数中的令牌的名称

class Norm
{
    const STR_NORM = 0;
    const INT_NORM = 0;
}

function foo($Arg1, $Arg2 = NULL)
{
    getConstName($Arg1); # Should Return STR_NORM;
    return $Arg1, $Arg2;
}

echo foo(Norm::STR_NORM);

有没有办法通过实现getConstName?

没有,因为在
foo()
中,
$Arg
的值就是整数0。它无法知道该值来自常量

例如,下面的示例应该输出什么

class Norm
{
    const STR_NORM = 0;
    const INT_NORM = 2;
}

echo foo( Norm::STR_NORM+2 );
echo foo( Norm::INT_NORM );

这两个回波是否都应输出
INT\u NORM

良好点。我必须考虑一下我的问题,我认为通常的解决办法是使每个常数都有一个不同的值。