[OOP]: Object-oriented programming: constructor (constructor)


Posted on 2015-08-18 10:17:34


Advanced PHP - As you know constructor is a special method, is executed immediately after creating the object. It is often used to initiate functions such as assigning attributes ...
Advanced PHP - As you know constructor is a special method, is executed immediately after creating the object. It is often used to initiate functions such as the value attributed to or create other objects from the object just created.

Report how Constructor

There are two ways to declare constructor: 1. Declare the function name identical to the name class 2. Use keywords that do function names __construct Of course like all other methods, the method or constructor can have no parameters passed. The .php file you create and run the code below to see results. Note: This is a very important method in object oriented programming php so you most certainly noticed it this method. Good luck!