class O
{
public $name = "test";
}
$a = new O();
$b = &$a;
$c = $a;
$d = clone($a);
$b->name = "demo";
echo $a->name; //demo
echo $b->name; //demo
echo $c->name; //demo
echo $d->name; //test
由此可见,clone()函数是新开辟一块内存来存储克隆的对象。
class O
{
public $name = "test";
}
$a = new O();
$b = &$a;
$c = $a;
$d = clone($a);
$b->name = "demo";
echo $a->name; //demo
echo $b->name; //demo
echo $c->name; //demo
echo $d->name; //test
由此可见,clone()函数是新开辟一块内存来存储克隆的对象。
转载于:https://www.cnblogs.com/wmzll/p/9122156.html