class A
{
static $inc;
private function __construct(){}
private function __clone(){}
public static function get_self()
{
if(!(self::$inc instanceof self)){
self::$inc = new self();
}
return self::$inc;
}
public static function get_static()
{
if(!(self::$inc instanceof self)){
self::$inc = new static();//主要就是实例static
}
return self::$inc;
}
public function geta(){
echo 111;
}
}
class B extends A
{
static $inc;
private function __construct(){}
private function __clone(){}
public function gethh(){
echo 222;
}
}
$obj = B::get_static();
//var_dump($obj);
//echo "<br />";
$obj->geta();
$obj->gethh();
标签:function,__,继承,self,private,一个,static,单例,inc
From: https://www.cnblogs.com/fuqian/p/17611058.html