I’m just learning OOP
Php, I understand the basic principles of OOP
programming, and trying to do exercises. I wanna do a simple messaging application, where users can message each other. Like email, but in a closed system.
My idea is when an user logs in, i create an user object that contains the function that an user can do and if an admin logs in i create an admin object that extends the user class with added admin functions.
My question is Can I check in other class if the object is an admin or an user class without injecting in the classes or create the objects inside the checking class. Like this:
class Checker{
// some variables
public function isAdmin($object ){
if($object istanceof Admin){
return 1;
} else{
return 0;
}
}
}