如何在PHP中检查方法是否是静态的?

Flu*_*ffy 7 php methods static

我需要知道该方法是否被声明为静态,因为它的名称和包含它的类的名称.method_exists提供true静态和非静态方法.

Nat*_*.B. 10

这里有一个关于如何使用ReflectionMethod的更清晰的方法:

$MethodChecker = new ReflectionMethod($ClassName,$MethodName);
var_dump($MethodChecker->isStatic());
Run Code Online (Sandbox Code Playgroud)


Eds*_*ina 6

使用ReflectionMethod :: isStatic

  • $method = new ReflectionMethod('NameOfClass', 'nameOfMethod'); $isStatic = $method->isStatic(); (2认同)