2009-09-26 81 views
3

我想知道是否有可能創建一個可以擴展另一個魔法對象的魔法對象(使用PHP)。魔法函數和繼承

+0

現在魔術發生在哪裏? – Gumbo 2009-09-26 15:02:43

+0

以及這兩個類正在使用神奇的方法 http://us2.php.net/manual/en/language.oop5.magic.php – Roch 2009-09-26 15:06:18

+1

@ Sbm007 __get和__set是神奇的方法,它們被稱爲每當你嘗試訪問非公共成員變量。 – MattBelanger 2009-09-26 16:37:56

回答

6

我不完全確定你在問什麼......你是否想明確調用父類的魔術方法?如果是這樣,你可以使用類'parent參考:

class Object extends dbObj{ 
    // ... 
    // this is what i'm assuming you're looking for: 
    public function __call($method, $variables){ 
     return parent::__call($method, $variables); 
    } 
}