INTERFACE AND ABSTRACT CLASS IN PHP

Опубликовано: 09 Октябрь 2024
на канале: learners adda
21
1

Abstract class
--------------
Abstraction is a way of hiding information .
In abstraction there should be at least one method
which must be declared but not defined.

The class that inherit this abstract class need to define
that method.

There must be a abstract keyword that must be used before
this class for it to be abstract class.

This class cannot be instantiated . only the class that implement
the methods of abstract class can be instantiated.
Interface

The class that is fully abstract is called interface.

Any class that implement this interface must use implements
keyword and all the methods that are declared in the class
must be defined here. otherwise this class also need to be
defined as abstract.

--one interface extends another interface
-- a class can implements interface.

Multiple inheritance is possible only in the case of interface.