.
Best for medium and large website project
There is something used in PHP opp to gain it oop functionalities like
Access Modifiers
OOP is actually based on his four core parts
Encapsulation
Class | Object |
Class is just a blueprint or a structure or templete which are actually used to build object | Object is a instacnce of a class |
Class is declare only once | Object can be created many time with different inputs and we can get different result everytime |
Classs does not allocate any memory | Object allocate memory when its created |
Classes is nothing without methods. methods are associated with class which perform some action when object of the class created.objects actually the function we define in the class or in simple words we define what we want as output from the class.
Access modifiers is a functionality which enable to control data flow like where we want to access them or not
we have three access modifiers
Private
Public is the default access modifiers and you can access it in anywhere
Can be access within the class and also in inherited class inherit by parent class
Private access modifier only be access inside the class where its define
Inheritance is the main fundamental concept of php which unlock the power of OOP. it enables code reusability and established connection between two classes. PHP does not support multi-inheritance
Abstraction helps to reduce complexity of code and it can be used as blueprint for other classes. its help to hiding the detail. Like when we use the some equipment like car you just need to press race instead of thinking how its run
Abstraction classes are declared with abstractio keywords here is the syntax how you make abstraction class
abstract class Connect
{
// Abstract methods and properties
}
Encapsulation is actually bundling related data into single unit. we perform encapsulation using setter and getther method
Allows objects of different classes to be treated as objects of a common superclass.