Ano*_* Wd 3 php clone reference class copy-initialization
是什么区别$a = &$b,$a = $b并且$b = clone $a在PHP OOP?$a是一个类的实例.
// $a is a reference of $b, if $a changes, so does $b.
$a = &$b;
// assign $b to $a, the most basic assign.
$a = $b;
// This is for object clone. Assign a copy of object `$b` to `$a`.
// Without clone, $a and $b has same object id, which means they are pointing to same object.
$a = clone $b;
Run Code Online (Sandbox Code Playgroud)
并使用References,Object Cloning查看更多信息.