-
魔術(shù)方法:__tostring()和__invoke()查看全部
-
final類不能被繼承,final方法被重寫 self parent static 相同的接口有不同的實(shí)現(xiàn)方法 取決于傳入的類的對象查看全部
-
final類不能被繼承,final方法被重寫 self parent static 相同的接口有不同的實(shí)現(xiàn)方法 取決于傳入的類的對象查看全部
-
<?php date_default_timezone_set("PRC"); class NbaPlayer{ public $name = 'Jordan'; public $height = '198cm'; public $weight = '98kg'; public $team = 'Bull'; public $playerNumber = '23'; function __construct($name,$height,$weight,$team,$playerNumber){ echo "In NbaPlayer construstor<br/>"; $this->name = $name; //$this是PHP中的偽變量,表示對象自身.可以通過$this->的方式訪問對象的屬性和方法 $this->height = $height; $this->weight = $weight; $this->team = $team; $this->playerNumber = $playerNumber; } //定義方法 public function run(){ echo "Running<br/>"; } public function jump(){ echo "Jumpping<br/>"; } public function shot(){ echo "Shotting<br/>"; } public function dribble(){ echo "Dribbling<br/>"; } } $jordan = new NbaPlayer('Jordan','198cm','98kg','Bull','23'); echo $jordan->name."<br/>"; $jordan->run(); echo '<hr/>'; //每一次用new實(shí)例化對象的時(shí)候,都會(huì)用類名后面的參數(shù)列表調(diào)用構(gòu)造函數(shù) $james = new NbaPlayer('James','203cm','120kg','Heat','6'); echo $james->name."<br/>"; $james->dribble(); $james->shot(); ?>查看全部
-
protected定義的屬性只能自身和子類可以訪問,出了 子類的大括號(hào) 就不可以訪問了??!查看全部
-
A是B B是父類,A是子類查看全部
-
對象是高內(nèi)聚低耦合的,低耦合更為重要,增加模塊的獨(dú)立性。 對象是類的一個(gè)實(shí)例 類的屬性和方法統(tǒng)稱為類成員查看全部
-
靜態(tài)屬性查看全部
-
對象:世間萬物皆對象,一個(gè)人,一架飛機(jī),一張桌子,包括可見與不可見之物查看全部
-
//當(dāng)對象不會(huì)再使用時(shí)才會(huì)觸發(fā)析構(gòu)函數(shù)查看全部
-
//析構(gòu)函數(shù)在程序執(zhí)行結(jié)束時(shí)會(huì)自動(dòng)調(diào)用 function __destruct(){ echo "destory".$this->name; }查看全部
-
構(gòu)造函數(shù) function__construct($name,$weight,$height){ $this->$name; $this->weight; $this->height; }查看全部
-
四個(gè)字,先入后出,先構(gòu)造的后析構(gòu)查看全部
-
要死用生物學(xué)來說,實(shí)例化對象就是用基因培養(yǎng)出來一個(gè)生物了,查看全部
-
類是差不多的物體的基本屬性,對象是單獨(dú)的每個(gè)物體查看全部
舉報(bào)
0/150
提交
取消