I have two classes and I am going to create an object from any one of these classes(based on some conditions), say classes are A
and B
and creating the object '$object' from any of these classes. These classes have some member variables, say A
has product_id
and B
has employee_name
. Can I call a member variable in following way (I am getting a parse error now.)
$object = new A; // or B;
$a = "product_id";// or "employee_name";
$object->$a = value;