How to implement in PHP that all properties of subclasses have toArray() method?
After calling, it becomes an array
How to design the parent class? ?
高洛峰2017-05-16 13:01:22
interface Arrayable {
public function toArray();
}
class parent implents Arrayable {
public function toArray() {
// to do
};
}
class children extends parent{
}
怪我咯2017-05-16 13:01:22
Write an interface implementation, or use the parent class for inheritance