class Grandfather {
protected function stuff() {
// Code.
}
}
class Dad extends Grandfather {
function __construct() {
// I can refer to a member in the parent class easily.
parent::stuff();
}
}
class Kid extends Dad {
// How do I refer to the stuff() method which is inside the Grandfather class from here?
}
我如何從Kid類中引用祖父類的成員?是否有一個引用PHP中祖父類成員的關鍵字?
我的第一個想法是Classname::method()
但有沒有關鍵字可用,如self
或parent
?
您是否嘗試過parent :: parent :: stuff()? – 2015-02-08 11:35:47
我還沒有嘗試過'parent :: parent :: stuff()'。你有任何進一步的信息嗎? – henrywright 2015-02-08 11:45:56
它不會工作@NomanUrRehman,它會像這樣casue語法錯誤:'PHP解析錯誤:語法錯誤,意外的'::'(T_PAAMAYIM_NEKUDOTAYIM)' – 2015-02-08 11:46:34