Examveda
Examveda

Which method introduced in PHP 5, is invoked just before an object is garbage collected?

A. __collect()

B. __garbage()

C. __destruct()

D. __destructor()

Answer: Option C

Solution(By Examveda Team)

You can use this method to perform any final cleaning up that might be necessary. Imagine, for example, a class that saves itself to a database when so ordered. I could use the __destruct() method to ensure that an instance saves its data when it is deleted.

This Question Belongs to PHP >> Object Oriented Concept

Join The Discussion

Related Questions on Object Oriented Concept