<分区>
我有 __construct($parameter)
public function __construct($nick) {
$query = "SELECT * FROM Users WHERE nick='".$nick."'";
$result = App::runQuery($query);
$user = $result->fetch_object();
$this->id = $user->id;
$this->nick = $user->nick;
$this->email = $user->email;
$this->password = $user->password;
$this->birthDay = $user->birthDay;
$this->sex = $user->sex;
$this->about = $user->about;
$this->city = $user->city;
$this->photo = $user->photo;
$this->following = $user->following;
$this->followers = $user->followers;
$this->statu = $user->statu;
}
现在我想要一个没有参数的默认构造函数,如下所示:
public function __construct() {
$this->id = NULL;
$this->nick = NULL;
$this->email = NULL;
$this->password = NULL;
$this->birthDay = NULL;
$this->sex = NULL;
$this->about = NULL;
$this->city = NULL;
$this->photo = NULL;
$this->following = NULL;
$this->followers = NULL;
$this->statu = NULL;
}
但是出了点问题,我得到这样的错误:
Fatal error: Cannot redeclare User::__construct() in /Applications/MAMP/htdocs/xxx/Application/User.php on line 33
如何同时拥有两个带参数和不带参数的构造函数?