????:<?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)?'是':'不是';
?? ???:查無此人?? ??:2019-06-10 09:09:56
???? ??:完成的不錯。編程有很多設計模式,多了解,對以后工作幫助很大。繼續(xù)加油。