简体   繁体   中英

Why not always use abstract instead of interface?

In PHP why not always use abstract instead of interface? I do know the following:

Use an interface when you want to force developers working in your system (yourself included) to implement a set number of methods on the classes they'll be building.

Use an abstract class when you want to force developers working in your system (yourself included) to implement a set numbers of methods and you want to provide some base methods that will help them develop their child classes.

if so why not always use abstract (when you want the functionality of an interface) without providing any base methods?

因为一个类可以实现多个接口,但是只能扩展一个抽象类。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM