我有一个要扩展的基类,但我无法弄清楚为什么我在基类中定义的变量不能被子类访问。我知道它们必须受到保护才能允许访问,但它们仍然对我不起作用。
class user {
protected static $username;
protected static $password;
protected static $remember;
function __construct() {
}
public function login($username, $password, $remember) {
$this->username = $username;
$this->password = $password;
$this->remember = $remember;
$login = new login();
}
}
class login extends user {
function __construct() {
print("user is: " . $this->username);
die();
}
}