what is Object Cloning in php?

后端 未结 5 1636
一个人的身影
一个人的身影 2020-11-30 23:26

Can someone explain me

  • what is Object Cloning in php?

  • When should i use clone keyword in php?

5条回答
  •  执笔经年
    2020-11-30 23:59

    As explained in other answers, clone makes a shallow copy of the object.

    If you need to make a deep copy (i.e. recursive copy), you can overload the __clone() methods.

    You can also use this library: MyCLabs\DeepCopy, which is more simple and powerful than a simple clone.

提交回复
热议问题