国产精品成人VA在线观看,亚洲日韩在线中文字幕综合,亚洲AV电影天堂男人的天堂,久久人人爽人人爽人人av东京热

News新聞

業(yè)界新聞動態(tài)、技術(shù)前沿
Who are we?

您的位置:首頁      樂道系統(tǒng)FAQ      PHP靜態(tài)延遲綁定和普通靜態(tài)效率的對比

PHP靜態(tài)延遲綁定和普通靜態(tài)效率的對比

標(biāo)簽: 發(fā)布日期:2017-10-20 00:00:00 303

PHP靜態(tài)延遲綁定和普通靜態(tài)效率的對比

只是一個簡單的小實(shí)驗(yàn),對比了下 延遲綁定 和 非延遲的效率

延遲綁定主要就是使用 static 關(guān)鍵字來替代原來的 self ,但功能非常強(qiáng)大了

實(shí)驗(yàn)代碼:

class A { 
  protected static $cc1 = array('a1', 'b', 'c', 'd'); 
  protected static $cc2 = array('a2', 'b', 'c', 'd'); 
  protected static $cc3 = array('a3', 'b', 'c', 'd'); 
  protected static $cc4 = array('a4', 'b', 'c', 'd'); 
  protected static $cc5 = array('a5', 'b', 'c', 'd'); 
 
  public static function n1() { 
    return static::$cc1; 
  } 
  public static function n2() { 
    return static::$cc2; 
  } 
  public static function n3() { 
    return static::$cc3; 
  } 
  public static function n4() { 
    return static::$cc4; 
  } 
  public static function n5() { 
    return static::$cc5; 
  } 
} 
 
class C extends A { 
 
} 
 
class B { 
  protected static $cc1 = array('a1', 'b', 'c', 'd'); 
  protected static $cc2 = array('a2', 'b', 'c', 'd'); 
  protected static $cc3 = array('a3', 'b', 'c', 'd'); 
  protected static $cc4 = array('a4', 'b', 'c', 'd'); 
  protected static $cc5 = array('a5', 'b', 'c', 'd'); 
 
  public static function n1() { 
    return self::$cc1; 
  } 
  public static function n2() { 
    return self::$cc2; 
  } 
  public static function n3() { 
    return self::$cc3; 
  } 
  public static function n4() { 
    return self::$cc4; 
  } 
  public static function n5() { 
    return self::$cc5; 
  } 
}