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

單例模式案例

原創(chuàng) 2019-06-06 14:07:16 199
摘要:<?phpclass Hubby{private function __construct() {}private function __clone() {}protected static $instance = null;public static function getInstance(){if(is_null(static::$instance)) {static::$instan

<?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();

$hubby1 = Hubby::getInstance();

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

echo '<br>';

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


批改老師:查無此人批改時(shí)間:2019-06-10 09:09:56
老師總結(jié):完成的不錯(cuò)。編程有很多設(shè)計(jì)模式,多了解,對(duì)以后工作幫助很大。繼續(xù)加油。

發(fā)布手記

熱門詞條