mysqlConn = new MysqlConn(); $sql = "select * from e_user where username='$name' "; //查询的sql $rs = $this->mysqlConn->query($sql); $this->userInfo = $this->mysqlConn->next(); $this->getInfo(); //调用传递信息的方法. } // 获取信息传递给属性的方法 protected function getInfo(){ $this->userName = $this->userInfo["username"]; $this->userPSW = $this->userInfo["userpsw"]; $this->userAge = $this->userInfo["userage"]; $this->userGrade = $this->userInfo["usergrade"]; } //返回每个属性的public 方法. public function getUserName(){ return $this->userName; } protected function getUserPSW(){ return $this->userPSW; } public function getUserAge(){ return $this->userAge; } public function getUserGrade(){ return $this->userGrade; } } ?>