php単例モード
502 ワード
class DB{
static private $_instance;
public $name='name';
private function __construct(){
}
static public function getInstance(){
if(!(self::$_instance instanceof self)){
self::$_instance = new self();
}
return self::$_instance;
}
public function __clone(){
trigger_error(' ',E_USER_ERROR);
}
public function test(){
echo ' ';
}
}
//$db = new DB();
$db = DB::getInstance();
$db_clone = clone $db;