-
魔術方法:__tostring()和__invoke()查看全部
-
final類不能被繼承,final方法被重寫 self parent static 相同的接口有不同的實現方法 取決于傳入的類的對象查看全部
-
final類不能被繼承,final方法被重寫 self parent static 相同的接口有不同的實現方法 取決于傳入的類的對象查看全部
-
<?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實例化對象的時候,都會用類名后面的參數列表調用構造函數 $james = new NbaPlayer('James','203cm','120kg','Heat','6'); echo $james->name."<br/>"; $james->dribble(); $james->shot(); ?>查看全部
-
protected定義的屬性只能自身和子類可以訪問,出了 子類的大括號 就不可以訪問了?。?查看全部
-
A是B B是父類,A是子類查看全部
-
對象是高內聚低耦合的,低耦合更為重要,增加模塊的獨立性。 對象是類的一個實例 類的屬性和方法統稱為類成員查看全部
-
靜態屬性查看全部
-
對象:世間萬物皆對象,一個人,一架飛機,一張桌子,包括可見與不可見之物查看全部
-
//當對象不會再使用時才會觸發析構函數查看全部
-
//析構函數在程序執行結束時會自動調用 function __destruct(){ echo "destory".$this->name; }查看全部
-
構造函數 function__construct($name,$weight,$height){ $this->$name; $this->weight; $this->height; }查看全部
-
四個字,先入后出,先構造的后析構查看全部
-
要死用生物學來說,實例化對象就是用基因培養出來一個生物了,查看全部
-
類是差不多的物體的基本屬性,對象是單獨的每個物體查看全部
舉報
0/150
提交
取消