Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
395 views
in Technique[技术] by (71.8m points)

PHP里面使用trait+interface配合工作是不是可以完美实现多重继承?

基本上就是如题所说了。感觉挺好用的。

目前我唯一感觉到的微小麻烦,就是ide不会认为两者的方法有关联。


回答的人最好有相关的尝试。并不是只用trait,而是和接口配合使用。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Trait 本身就是用来解决多重继承问题的,但他并不是原始意义上的多重继承,所以不会关联到父类或者父接口上,他只进行覆盖,逻辑和多重继承是有区别的。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...