原文:this,self::,static::的區別

self:: 代表當前類,可訪問類內靜態屬性 靜態方法 非靜態方法和常量。但不能訪問非靜態屬性 訪問方式:self:: 靜態屬性 靜態方法 非靜態方法 常量 ,如self:: a self不帶 ,變量帶 this 代表當前類對象,不可訪問類內靜態屬性 靜態方法和常量。 訪問方式: this gt 變量 方法 ,如 this gt a this帶 ,變量不帶 static:: 與self::相比,s ...

2019-06-05 00:47 0 483 推薦指數:

查看詳情

PHP中staticself區別

PHP中staticself的使用區別 class A { public static function who() { echo __CLASS__; } public static function test ...

Wed May 23 22:50:00 CST 2018 0 1357
PHP 中 staticself區別

使用 self:: 或者 __CLASS__ 對當前類的靜態引用,取決於定義當前方法所在的類: 使用 static:: 不再被解析為定義當前方法所在的類,而是在實際運行時計算的。也可以稱之為“靜態綁定”,因為它可以用於(但不限於)靜態方法的調用。 靜態綁定是PHP 5.3.0,增加的一個功能 ...

Wed Oct 12 23:58:00 CST 2016 1 9856
PHP 中 new static 和 new self區別

今天老大在公司 問了一下 new static 和 new self區別 公司十個程序 竟然沒有一個回答上來 后面畫面自補 。。。 本屌絲回家后 就百度了解了下 這二者區別 : 使用 self:: 或者 __CLASS__ 對當前類的靜態引用,取決於定義當前 ...

Wed Jul 29 07:01:00 CST 2015 1 3098
PHP中new self()和new static()的區別探究

1.new static()是在PHP5.3版本中引入的新特性。 2.無論是new static()還是new self(),都是new了一個新的對象。 3.這兩個方法new出來的對象有什么區別呢,說白了就是new出來的到底是同一個類實例還是不同的類實例呢? 為了探究上面的問題,我們先上一段 ...

Thu Jan 12 18:31:00 CST 2017 0 20355
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM