Shallow clone: Only non-object non-resource data in the cloned object, that is, the object's property is stored in the object type, the clone will appear incomplete
classB{public$val = 10;}classA{public$val = 20; public$b; publicfunction__construct(){$this->b = new B(); }}$obj_a = new A();$obj_b = clone$obj_a;$obj_a->val = 30;$obj_a->b->val = 40;var_dump($obj_a);echo'
';var_dump($obj_b);
Deep Clone: All property data for an object is completely duplicated, requires a magic method __clone (), and a deep clone inside it
classB{public$val = 10;}classA{public$val = 20; public$b; publicfunction__construct(){$this->b = new B(); } publicfunction__clone(){$this->b = clone$this->b; }}$obj_a = new A();$obj_b = clone$obj_a;$obj_a->val = 30;$obj_a->b->val = 40;var_dump($obj_a);echo'
';var_dump($obj_b);
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above introduces the cloning clone of PHP, including the content, I hope that the PHP tutorial interested in a friend helpful.