👋 Enjoying the content? Subscribe to our Medium publication for more articles like this. 👇
Keep Learning

Interface And Abstract Class

BY Atakan Demircioğlu
Table of Contents

Interfaces and abstract classes with PHP examples.

Interface And Abstract Class image 1

Interface And Abstract Class

My notes about interfaces and abstract classes with PHP examples.

What is an interface?

In very basic words, it is a contact or signature. Any class that implements an interface must be expected to have the same behavior. That means if you define a method contact that takes two params and returns a string, the class that implemented this interface must take the same behavior.

Let us discuss with an example;

Firstly it is a good example of the interface segregation principle (ISP) and we can discuss this principle in another article.

What is Concrete Class?

A concrete class is a class that we can create an instance of, using the new keyword.

What are the advantages of using Interfaces?

What is Abstract Class?

It basically defines an interface for other classes to extend but has some differences.

Here is a basic example of usage;

Differences with Abstract Class and Interface