人人人妻人人人妻人人人,99精品国产综合久久久久五月天 ,欧美白人最猛性XXXXX,日韩AV无码免费播放

News新聞

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

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

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

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

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

只是一個簡單的小實驗,對比了下 延遲綁定 和 非延遲的效率

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

實驗代碼:

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; 
  } 
}