cloning a php object

by Prakash 2013-11-12 15:32:51

This way we can clone an object in php :


$object = new MyObject();
$object->setId(5);
$copy_of_object = clone $object;
print_r($object);
echo "<br />
print_r($object); // same result as object 1

Tagged in:

493
like
0
dislike
0
mail
flag

You must LOGIN to add comments