CONSTRUCTOR in PHP

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

  1. 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:-