首頁 > 問答 > 主體
class DBmodel{ private $name; publice function delete($name){ $this->name = $name; } }
裡面的$this代表的是整個類別DBmodel,還是類別方法delete ?
autoload2021-10-11 09:34:18
$this代表的是對象,而$this所在環境為類別內部的方法內部,所以$this物件是在類別內部存取
A _ Q _i_2021-10-10 19:56:16
//如果里面有构造方法: function __construct(){ $this->name = $name; }
裡面的$this代表的就是建構方法本身嗎?
$this->name 代表的是這個類別中的name屬性