有人能告诉我这个mysqli登录代码出了什么问题吗


Can anyone tell me whats wrong with this mysqli login code?

我正在使用mysqli登录,但我一直收到这些错误。https://i.stack.imgur.com/TmUAw.png

<?php
class Database {
  public function __construct() {
    $host = 'localhost';
    $user = 'root';
    $pass = 'login';
    $name = 'meeboo1';
    $this->mysqli = new mysqli($this->host, $this->user, $this->pass, $this->name);
  }
}
?>

有人能告诉我我做错了什么吗?我以为他们已经申报了?

您应该尝试访问函数内部定义的变量,如下所示:

$this->mysqli = new mysqli($host, $user, $pass, $name);