Object Oriented Programming using PHP

Опубликовано: 29 Июль 2026
на канале: Shantanu Mukherjee
95
4

Object Oriented Programming using PHP. OOPS in PHP

1. Class
2. Objects
3. Constructor
4. Encapsulation
5. Inheritance
6. Interface
7. Abstract Class
8. Polymorphism

1. Class is a collection of objects.

2. Object is an instance of class.

3. __construct() it will automatically called on creation of an object. __destruct() function which is automatically called at the end of the script.

4. Encapsulation is about access of data and method in a class. Properties and methods can have access modifiers which control where they can be accessed.
public - the property or method can be accessed from everywhere. This is default
protected - the property or method can be accessed within the class and by classes derived from that class
private - the property or method can ONLY be accessed within the class.

5. Inheritance - Inheriting the properties or functionalities from one class to another class using the extends keyword.

6. Interface - Through Interface you can achieve multiple inheritance property. Interfaces also worked like abstract classes.

7. Abstract Classes: Abstract classes are those classes where functions are declared but not used and need its child class to fill out the tasks.

8. Polymorphism - Polymorphism means more than one form
Method overloading is the example of compile time polymorphism. Method overriding is the example of run time polymorphism.
Overloading - more than one function can have same method signature but different number of arguments.
Overriding, more than one functions will have same method signature and number of arguments.