I have 3 files:
main.php (all the site code) AccountHandler.class.php (handles login/logout/get acc details) User.class.php (Plain object, getters and setters for generic user traits)
In the 'login' function in AccountHandler, it checks the password is correct and then returns the details on file for the account. I wish to then instantiate a 'User' object and fill it with these details, returning said object from the function.
However, on the other end, in main.php where the function was originally called i need to be able to recognise the 'User' object and access the values.
How can i include the User class file in BOTH the AccountHandler class AND the main.php such that they can both use the 'User' class?
Does any of that make sense?
class User
{
private $email;
private $username;
private $role;
public function __construct($email, $username, $role)
{
$this->setUsername($username);
$this->setEmail($email);
$this->setRole($role);
}
public function getEmail(){
return $this->email;
}
public function setEmail($email){
$this->email = $email;
}
public function getUsername(){
return $this->username;
}
public function setUsername($username){
$this->username = $username;
}
public function getRole(){
return $this->role;
}
public function setRole($role){
$this->role = $role;
}
}