interface A {
public function code();
}
interface B {
public function code(string $string);
}
class C implements A,B {
//...code
}
当C同时需要实现这两个接口的时候,有什么方法同时使用 A,B两个接口中的code方法????
本地测试只能使用其中一个方法
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
有个粗挫的方法,你把AB接口的具体逻辑都整合到C接口里面,直接调用C接口^_^
本身这种写法就是个尝试错误,公用方法写在外面,类中直接调用,不要每一个口都写个一样的,维护起来也巨麻烦
可以了解一下PHP的性状。
php不支持多态, 所以最好避免这种写法