The example you have given probably won't work for what you are trying to accomplish. It is not clear what function userdata does. Revised:
class User {
private $id;
private $username;
private $password;
private $email;
private $admin;
public function __construct($id, $username, $password, $email, $admin) {
$profileData = user_data($profile_user_id
,'id'
,'username'
,'password'
,'email'
,'admin');
$this->id = $profileData ['id'];
$this->username = $profileData ['username'];
$this->password = $profileData ['password'];
$this->email = $profileData ['email'];
$this->admin = $profileData ['admin'];
}
public function getId(){ return $this->id; }
public function getUsername(){ return $this->username; }
public function getEmail(){ return $this->email; }
public function getAdmin(){ return $this->admin; }
public function setAdmin($admin){ $this->admin = $admin; }
}
The variables are set private. Only the user object should have access to the data directly. However, other objects might want to retrieve the data, which is why there are 4 public get functions. getPassword was omitted because you probably don't want that one publicly available. Also, it is concievable you might set a new admin, so a public setter function was added as well. you would instance the new user (that is, take the class and make a real example of it) thusly:
$user1 = new User(1);
And during usage you would echo these variables by:
echo $user1->getUsername();
Please accept my apologies for not directly answering your question, but that example is headed for trouble.