Question:What are constructor and destructor? 

Answer Constructor: A constructor is defined as a block of code that automatically executes at the time of object instantiation. Constructors can accept parameters, call class methods or  other functions.PHP recognizes constructor by the  name__construct.  The general  Syntax→
        function__construct([argument1,argument2,….,argumentN]){
            //Class initialization code  
        }
Destructor:
 We can use destructors to modify the object destruction process.Derstructors are  created like any other method but must be titled    __destruct().   Syntax→    
function__destruct(). 

+ Report
Total Preview: 740
What are constructor and destructor?
Copyright © 2025. Powered by Intellect Software Ltd