public function __construct($username)
{
require("config.php");
$conn = new mysqli($server, $user, $pass, $db);
$conn->query('set names gb2312');
$res = $conn->query("SELECT * FROM test where name='$username'");
$this->userInfo = $res->fetch_assoc();
$conn->close();
$this->getUserInfo();
}
public function getUserInfo()
{
$this->name = $this->userInfo['name'];
$this->pass = $this->userInfo['pass'];
$this->age = $this->userInfo['age'];
$this->tel = $this->userInfo['tel'];
}
public function getUserName()
{
return $this->name;
}
public function getUserPass()
{
return $this->pass;
}
public function getUserAge()
{
return $this->age;
}
public function getUserTel()
{
return $this->tel;
}
}
$user = new UserInfo('小破孩');
echo $user->getUserName();
echo $user->getUserTel();