CONSTRUCTOR in PHP
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
Constructor is a method (FUNCTIONJ) defined inside a class is called automatically at the time of creation of object. Main aim of a constructor method is to initialize the object. In PHP, a method of special name __construct acts as a constructor.
There are two type of constructor in PHP
- Default constructor
2. Parameterized constructor
Default constructor
In default constructor ther are no parameter passed during the creation of constructor.
eg:-
Parameterized constructor
In parameterized constructor the are one or more than one parameter passed during the creation of constructor.
eg:-