1.

Which method introduced in PHP 5, is invoked just before an object is a garbage collected?(a) __collect()(b) __garbage()(c) __destruct()(d) __destructor()I got this question during an online exam.I'm obligated to ask this question of Object Advanced Features topic in division Objects and Databases in PHP of PHP

Answer» CORRECT ANSWER is (c) __destruct()

To explain: 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.


Discussion

No Comment Found

Related InterviewSolutions