Clone is not working for me?

前端 未结 3 635
感动是毒
感动是毒 2020-12-11 23:39

I have an object $objDummy of some class ClassDummy and another is as

$objClone = clone $objDummy;

Then I make any ch

3条回答
  •  轮回少年
    2020-12-11 23:45

    You can do this, but not for objects with methods ->

    function cloneObj(&obj) {
     return json_decode(json_encode($obj));
    }
    
    $a = new stdClass();
    $b = cloneObj($a);
    

提交回复
热议问题