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

單例模式數(shù)據(jù)庫(kù)連接對(duì)象

Original 2019-06-13 15:20:08 199
abstrakt:<?phpclass Hubby{ private function __construct(){} private function __clone(){} protected static $instance=null; public static function getInstance() { if (is_null(static::$instance)){ static::$

<?php



class Hubby

{


private function __construct(){}

private function __clone(){}



protected static $instance=null;



public static function getInstance()

{

if (is_null(static::$instance)){

static::$instance=new static();

}


return static::$instance;

}

}



$hubby1=Hubby::getInstance();

$hubby2=Hubby::getInstance();

echo( $hubby1 instanceof hubby)?'是':'不是';

echo '<br>';

echo( $hubby2 instanceof hubby)?'是':'不是';

echo '<br>';

echo($hubby1===$hubby2)?'完全相等':'不相等';

echo '<br>';

var_dump($hubby1,$hubby2);


Korrigierender Lehrer:天蓬老師Korrekturzeit:2019-06-13 17:07:25
Zusammenfassung des Lehrers:?jiǎn)卫J降膽?yīng)用場(chǎng)景 還是很多... 很多類(lèi),為了效率, 不允許多重實(shí)例化

Versionshinweise

Beliebte Eintr?ge