时间:2021-07-01 10:21:17 帮助过:13人阅读
class A //核心
{
public $db;
public function __construct(){
$this->db=new B();
}
public function find(){
return $this->db->b1();
}
}
class B //数据库
{
public function b1(){
return true;
}
public function b2(){
return false;
}
}
//**********分隔符***********
class C extends A //第三方类
{
static function test(){
return self::find();
}
}
//当前文件
if(C::test()){
echo 'OK';
}
?>
class A //核心OK
{
private static $_Instance;
public $db;
public function __construct(){
$this->db=new B();
}
public function find(){
if(empty(self::$_Instance)) self::$_Instance = new self();
return self::$_Instance->db->b1();
}
}
class B //数据库
{
public function b1(){
return true;
}
public function b2(){
return false;
}
}
//**********分隔符***********
class C extends A //第三方类
{
static function test(){
return self::find();
}
}
error_reporting(E_ALL ^ E_STRICT);
//当前文件
if(C::test()){
echo 'OK';
}