[英]Assigning object to a new class
I have a class: 我有一堂课:
$b = new Model();
And I have a different class: 我有一个不同的班级:
$c = new Model();
I want $b
to be $c
. 我希望
$b
成为$c
。
How do I accomplish this? 我该如何完成?
$b = $c
$b now references $c both refer the the same instance* $b = $c
$ b现在引用$ c都引用相同的实例*
$b = clone $c;
$b is a copy of $c each refers to a different instance of the Model* $ b是$ c的副本,每个副本都引用模型的不同实例*
*improved by Ryan Vincent *由Ryan Vincent改进
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.