在这段代码中
<?php
$object1 = new User();
$object1->name = "Alice";
$object2 = clone $object1;
$object2->name = "Amy";
echo "object1 name = " . $object1->name . "<br>";
echo "object2 name = " . $object2->name;
class User
{
public $name;
}
?>
clone
使用而不仅仅是使用的好处是new
什么?除了我们新定义的之外,我们是否会为object1
in的属性获得所有相同的值?object2
name