As seen in the best practices for Android and PHP development, "PHP interface costs very high please use abstract classes instead of interfaces as much as possible," a bit dizzy, for specific analysis.
Reply content:
As seen in the best practices for Android and PHP development, "PHP interface costs very high please use abstract classes instead of interfaces as much as possible," a bit dizzy, for specific analysis.
Performance level, I can not analyze this side, I do not think it is necessary to analyze.
Abstract classes, and interface classes appear to be different, and they are used differently.
interface classes, which are defined by some interface standards, are defined only as not implemented. The class that implements the interface class, to express, I have the method of definition in the interface class, but the concrete implementation way is different.
Abstract class, is can implement concrete methods, inherit the class of abstract class, I use the method of abstract class, including concrete implementation (subclass can also override method, Overwrite parent class)
Note that I am saying that 实现接口类 , 继承抽象类 in PHP only extends one parent class (including abstract classes), but can be implements more than one interface class, this is in the usage of the distinction.
I have not seen the book you mentioned, I think, to have their own discrimination, reasonable use.
There is a small difference in the real-time performance, but for the maintainability of the program, sacrificing a little bit of performance is also acceptable.
$className="xxx";$instance=new $className;
Is this a interface or an abstract class?