PHP copy all object properties to this
问题 I have an object in PHP, of the type MyObject . $myObject instanceof MyObject Now, in the class MyObject , there is a non-static function, and in there, I use the reference to "me", like $this , but I also have another object there. Is it possible, without doing $this = $myObject , to achieve more or less the same effect, like something of the sort set_object_vars($this, get_object_vars($myObject)) ? 回答1: <?php class MyObject { public function import(MyObject $object) { foreach (get_object