1.

Which one of the following is the right way to clone an object?(a) _clone(targetObject);(b) destinationObject = clone targetObject;(c) destinationObject = _clone(targetObject);(d) destinationObject = clone(targetObject);This question was addressed to me in exam.I'm obligated to ask this question of Advanced Object-Oriented PHP topic in chapter Object-Oriented PHP of PHP

Answer»

Correct choice is (b) destinationObject = clone targetObject;

Easy EXPLANATION: You can clone an OBJECT by prefacing it with the clone KEYWORD. A copy of an object is created by using the clone keyword. $copy_of_object = clone $object;



Discussion

No Comment Found

Related InterviewSolutions