2009-11-11 18 views
2

我知道它不會完全等同於$ this,但有沒有一種方法可以從內部引用靜態類,而不使用類本身的名稱? (如超級,但本身) 這只是一種方法,以避免必須重構所有類的引用,如果類被重命名。

例子:

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

回答

8
self::method(); 
+1

生病添加..閱讀本http://php.net/manual/en/language.oop5.php – Galen 2009-11-11 00:20:20