Clone object clone
In PHP, we can clone the same object according to the existing object. After cloning, the original object and the replica object are completely independent and do not interfere with each other.
The result of running the code is:
If you need to re-assign initial values to the member properties of the cloned replica object when it is cloned, you can declare a magic method _ _ clone () in the class. This method is called automatically when the object is cloned, so the cloned copy can be reinitialized by this method. The _ _ clone () method takes no parameters, and it automatically contains references to the $this and $that objects, $this is the reference to the copy object, and $that is the reference to the original object.
The result of running the code is: