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? ?
闭关修行中......
interface Arrayable { public function toArray(); } class parent implents Arrayable { public function toArray() { // to do }; } class children extends parent{ }
Just write a toarray method for the parent class, that’s it,
Write an interface implementation, or use the parent class for inheritance
Just write a toarray method for the parent class, that’s it,
Write an interface implementation, or use the parent class for inheritance