php单例模式
单例模式,说白了就是说一个类只能实例化一次
db类、config类都会用到,经常用的类 减少new的次数
<?php
class Single
{
private static $_instance = null;
private function __construct()
{
}
private function __clone()
{
}
public static function getInstance()
{
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
}

浙公网安备 33010602011771号