如何在PHP中的类之间传递变量而不进行扩展

So, I've got my setup like this:

class System extends mysqli{

    function __construct(){
         //user variables such as $this->username are returned here
    }

}

$sys = new System();

class Design{

    function setting(){
        echo $sys->username;
    }

}

$design = new Design();

Yet the Design class doesn't echo the username. I can echo the username outside of the Design class, but not inside the design class. How can I go about this?

Everyone else's answer is fine, but you can inject the dependency on system very nicely:

class Design{

    private $sys;

    public function __construct(System $sys) {
       $this->sys = $sys;
    }

    function setting(){
        echo $this->sys->username;
    }
}
$sys = new System;
$design = new Design($sys);

Your Design class has no access to the $sys variable.

You have to do something like this:

class System extends mysqli{

    function __construct(){
         //user variables such as $this->username are returned here
    }

}

class Design{

    private $sys;

    function __construct(){
        $this->sys = new System();
    }

    function setting(){
        echo $this->sys->username;
    }

}

$design = new Design();

That's because $sys isn't in the scope of the Design class.

function setting(){
    $sys = new System();
    $sys->username;
}

should work, assuming that username is public.