Condition Based inheritance?

aatkco

New Member
I am trying to inherit a set of different parent class and even not inherit any class but as per some condition.For example, Here is what I would like to do\[code\]$choice = 2;switch($choice) { case 1: class child extends parent1 break; case 2: class child extends parent2 break; default: class child //extend nothing break; }\[/code\]I think you can figure out what I am trying achieve here.parent classes\[code\]class car { }\[/code\]Child classes\[code\]class ferari extends car { }class ford extends car { }\[/code\]grandchild classes \[code\]class automaticcar { }class manualcar { }\[/code\]Now this grandclasses need to interit a parent as per the value sent from the form using post. Something like this\[code\]$brand = $_POST['brand'];if(isset($brand) && !empty($brand)) { class automaticcar extends $brand }else { class automaticcar extends car //or even nothing}\[/code\]\[code\]//And then I wish to write the remaining portion of the clas\[/code\]s
 
Back
Top