Tell me what are the __construct() and __destruct() methods in a php class?



Tell me what are the __construct() and __destruct() methods in a php class?..

Answer / Shivani Sharma

__construct() is a special method that gets called when an object is instantiated. It's used for initializing the properties of a new object. On the other hand, __destruct() is called when the object is about to be destroyed or when the script finishes execution. It's used for cleaning up resources that the object may have acquired during its lifetime.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

Binary tree question - Node has numeric data (int) The function takes depth as argument and sum all the value of the node of the depth. For instance, (0) depth 0 / \ 10 20 depth 1 / \ / \ 40 50 60 70 depth 2 so if you pass get_sum(2), you would return 220 which is 40+50+60+70 (sum of depth2) write the function.

1 Answers   Amazon, FGD,


What is an array in php?

1 Answers  


What is $row in php?

1 Answers  


What do you mean by having php as whitespace insensitive?

1 Answers  


What is the difference between $_files['userfile']['name'] and $_files['userfile']['tmp_name']?

1 Answers  


Tools used for drawing er diagrams?

1 Answers  


What is abstract class in php?

1 Answers  


Explain what are psrs?

1 Answers  


What is http get and post?

1 Answers  


Why super () is used in java?

1 Answers  


What is php limit?

1 Answers  


What is the difference between php and java?

1 Answers  


Categories