OOPS BASIC CONCEPTS IN PHP
Following are the OOPS basic concepts in php
- Class and Object
A class act as blueprint from which lot of individuals object can be created.
1.Class and Object:
Class and objects are the main part of OOPS.Class is a programmer-defined data type which includes local method and local variablesObject An individual instance of the data structure defined by class.Simple Words one class contain many objects they belong it. A class act as blueprint from which lot of individuals object can be created. When the object is created they inherit a same properties and behavior although each object may have different value for certain properties.
2 Constructor :
Constructor is the key part of OOPS PHP. Constructor is a special type of function of the class which is automatically call whenever the object is created.
Destructor is work like a garbage Collector which always focus over the object whenever no needed the object it destroy automatically.
In inheritance , we have a parent class with its own methods and properties, and child class that can use the code from the parent. By Using inheritance, we can a reusable piece of code that we write only in the parent class and child class access it.
Poly means “many” and morphism means property which helps to assign more than one property.
Abstraction is a concept in which a class has methods with implementation. The idea is to have a template and let the child class that inherits the parent class implement the method.
Wrapping up data member and data method together into a single unit is called Encapsulation. For example encapsulation is just like enclosing into a capsule.