class my{
protected static $obj;
public function __construct(){
}
public static function getInstace(){
if(self::$obj===null){
self::$obj = new self();
echo "init ";
}
return self::$obj;
}
public function getTitle(){
echo "I am is Title";
}
public function getContent(){
echo "I am is content";
}
}
$obj = my::getInstace();
$obj->getTitle();
$obj->getContent();
单例模式设计
猜你喜欢
转载自blog.csdn.net/lemqs0123/article/details/80858052
今日推荐
周排行