Classes are a way of describing the blueprint of an object.
Fundamental principles of OOP
Allows a class to override or extend the functionality of a base class.
Allows complex logic to be abstracted out. Achieved using interfaces and abstract classes.
– Cannot be instantiated.
– It defines or partially implements the methods for any class that extends it.
– An abstract method cannot have an implementation.
– Any class that inherits from an abstract class, all abstract methods must be implemented by the derived class or they must be declared abstract.
– Unlike interfaces, abstract classes may have methods with full implementation and may also have defined member fields.
– An interface is not a class.
– Interfaces join types that are unrelated.
– Can only define method names, has no implementation.
– Any class that implements an interface must implement all the methods it defines or it must be declared abstract.
Difference between abstraction and interface
Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.
Encapsulation hides the implementation details of a class from the object. In Encapsulation, the data is not accessed directly; it is accessed through the functions present inside the class. In simpler words, attributes of the class are kept private and public getter and setter methods are provided to manipulate these attributes. Thus, encapsulation makes the concept of data hiding possible.
Polymorphism is the process of using function in different ways for different object types (method overriding).
A class can implement many interfaces and inherit only one class (even if that class is abstract)
Excellent article on PHP OOP:
http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-20-object-oriented-programming-principles/#_Toc362296568 (For C# but the concepts are the same)