'&'符號是和'='在一起使用 =&?還是和'$'符一起 &$james?還是單獨添加?
2018-01-16
其實講解的老師表達的意思應該是“self不能訪問自身的非靜態屬性”
this self static用于類自身數據訪問,parent用于父類數據訪問
對于屬性,this可以訪問非靜態屬性,self static parent用于靜態屬性。
對于方法,this self parent可以訪問靜態、非靜態方法,static可以訪問靜態方法。
$this-> 屬性[動] + 方法[靜/動];
self:: 屬性[靜] + 方法[靜/動];
parent:: 屬性[靜] + 方法[靜/動];
static:: 屬性[靜] + 方法[靜];
this self static用于類自身數據訪問,parent用于父類數據訪問
對于屬性,this可以訪問非靜態屬性,self static parent用于靜態屬性。
對于方法,this self parent可以訪問靜態、非靜態方法,static可以訪問靜態方法。
$this-> 屬性[動] + 方法[靜/動];
self:: 屬性[靜] + 方法[靜/動];
parent:: 屬性[靜] + 方法[靜/動];
static:: 屬性[靜] + 方法[靜];
2018-01-03
$jordan = new NbaPlayer("Jordan", "198cm", "98kg", "Bull", "40", 20, true);
echo $jordan->height; //報錯 無權限
echo $jordan->isHungry; //不報錯 返回1即true
var_dump($jordan); //查看對象標示符中的數據結構發現有兩個isHungry屬性:
private 'isHungry' (Human) => boolean true
public 'isHungry' => boolean true
怎么回事???有大神解釋一下不?
echo $jordan->height; //報錯 無權限
echo $jordan->isHungry; //不報錯 返回1即true
var_dump($jordan); //查看對象標示符中的數據結構發現有兩個isHungry屬性:
private 'isHungry' (Human) => boolean true
public 'isHungry' => boolean true
怎么回事???有大神解釋一下不?
2018-01-01