亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

靜態(tài)綁定技術(shù)調(diào)用

原創(chuàng) 2019-03-28 10:39:40 324
摘要:<?php // new static 得到的單例分別為D,E和F。 class D {  protected static $_instance = null;    protected function __construct(){}  protec
<?php
// new static 得到的單例分別為D,E和F。
class D
{
 protected static $_instance = null;
 
 protected function __construct(){}
 protected function __clone()
 {
  //disallow clone
 }
 
 static public function getInstance()
 {
  if (static::$_instance === null) {
   static::$_instance = new static();
  }
  return static::$_instance;
 }
}
 
class E extends D
{
 protected static $_instance = null;
}
 
class F extends D{
 protected static $_instance = null;
}
 
$d = D::getInstance();
$e = E::getInstance();
$f = F::getInstance();
 
var_dump($d);
var_dump($e);
var_dump($f);

?>


批改老師:天蓬老師批改時(shí)間:2019-03-28 10:47:02
老師總結(jié):你就是后期靜態(tài)綁定, 用在靜態(tài)繼承的上下文環(huán)境中

發(fā)布手記

熱門詞條