replicate the parent object you want to create a new instance of
this other object so that the replica has its own separate copy.
- An object copy is created by calling the object's __clone()
- method.
+ An object copy is created by using the clone operator.
Example:
<?php
- $copy_of_object = $object->__clone();
+ $copy_of_object = clone $object;
?>
When the developer asks to create a new copy of an object, the
print $obj->id . "\n";
- $obj = $obj->__clone();
+ $obj = clone $obj;
print $obj->id . "\n";
print $obj->name . "\n";