I can't seem to find an answer to this albeit I am probably not looking for the right thing being new to classes and oop. I would like to know if you can use a variable when calling a class method.
When a user logs into my system I wish to display them some chart on a dashboard based on their user role.
For starters here is an example of my class
class Dashboard
{
function get_guest_graph1()
{
return 'guest graph';
}
function get_user_graph1()
{
return 'user graph';
}
}
On the page I can echo say
$user->userRole;
This will return either guest or user.
So once I have established the role and put this into a varible ie
$role
Is there a way I can then do the following?
Dashboard::get_$role_graph1();