【问题标题】:Is there an equivalent to $this for static classes? ( kind of super but for the current class where it is used )静态类是否有等效于 $this 的方法? (有点超级,但对于当前使用它的类)
【发布时间】:2009-11-11 00:13:36
【问题描述】:

我知道它不会完全等同于 $this,但是有没有一种方法可以在不使用类本身的名称的情况下从其内部引用静态类? (像超级但为自己) 如果类被重命名,这只是避免重构所有类引用的一种方法。

例子:

class foo {
    function bar() {
        static_this::method();
        // instead of:
        foo::method();
    }
 }

【问题讨论】:

    标签: php class static reference this


    【解决方案1】:
    self::method();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-07
      • 1970-01-01
      • 2012-06-06
      • 1970-01-01
      • 1970-01-01
      • 2011-05-17
      • 1970-01-01
      • 2010-11-30
      相关资源
      最近更新 更多