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 return 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.

There can be more than one methods that can left undefined.

Eg i

Output
Defined function b
Can be used as it is

in the above example class a is a abstract class and it contains a abstract method b().
the child class m inherit class a in which abstract method be is defined completely.

Eg ii

Output
hi

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.

Multiple inheritance is possible only in the case of interface.

Output
hi
hello

in above example there are two interfaces A and B. a class c implements both interfaces and define the methods f1() and f2()
of interfaces A and B respectively. if any of the method of interfaces are left undefined in the class that implements the interface then
it must be defined as abstract.


  • Sanjay Kumar Singh

    Hello phptpoint,
    I found that your tutorials are very helpful to study.

    I have a question basically not regarding from your tutorials ,
    can you make some tutorials on SEO , i.e how can we configure php websites via SEO.

    Thanks

    • Thank you very much for your valuable suggestion. Try to upload SEO Tutorial ASAP.