如何检查 PHP 是否处于静态上下文中(或不处于静态上下文中)?
有什么方法可以检查方法是静态调用还是在实例化对象上调用?
Is there any way I can check if a method is being called statically or on an instantiated object?
推荐答案
尝试以下操作:
class Foo {
function bar() {
$static = !(isset($this) && $this instanceof self);
}
}
来源:seancoates.com,来自 Google
Source: seancoates.com via Google
相关文章