Link to home
Start Free TrialLog in
Avatar of Brad Brett
Brad BrettFlag for United States of America

asked on

Check if variable exists inside class

I have the following PHP class:
 
class Class1
{
     public $var1;
     public $var2;
     public $var3;
}

Open in new window


How can I check if specific variable name is existed in Class1 or not?
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brad Brett

ASKER

I see that the function get_defined_vars() return array of all the defined variables, I only need to get the variables I defined in the class "$var1, $var2, and $var3".

How can I do that?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks,