class - PHP如何实现子类的属性全部都有 toArray()方法?
阿神
阿神 2017-05-16 12:59:22
0
3
505

PHP如何实现子类的属性全部都有 toArray()方法?

调用之后 ,变成了数组

父类如何设计呢??

阿神
阿神

闭关修行中......

reply all(3)
小葫芦
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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!