General Extending and Implenting Question

windows

Guest
I'm finally getting into PHP5 (been long enough). Is it possible and/or good practice for a class to both extend a class and implement an interface?Certainly is possible (try it and see). Good practice? The two concepts are independent. If extending an existing class is a good idea, do it; and if implementing an interface is a good idea, do that too.I have seen it done in some examples and tutorials, but I have not yet had cause to use such a pattern in any of my coding. (Or perhaps I am just not clever enough to have seen it as a good solution?)Well I have two types of people that differ greatly except for a few key commonalities. The class that adds these people in extends the class to add information to the db while implementing the interface defining the functions both people will need. Make sense?The most recent case I looked at was:

abstract class FormField extends PageComponent implements iBindable
{}

A "PageComponent" being something that can appear on a page, of which a FormField is a particular type; but not all PageComponents have properties that can be bound to an external data source. (And before you suggest BindablePageComponent, there are some non-PageComponents that are also iBindable).
 
Back
Top