<?php class a{ public $n; public function __construct($n) { $this->n=$n; $this->N=&$this->n; } } class b{ public $n; public function __construct($n) { $this->n=$n; } } class c{ public function t($b){ $cb= clone $b; $cb->n='clone'; var_dump($cb->n,$b->n); } } $c=new c(); $a=new a('new'); $b=new b('new'); $n=&$b->n; //Class A specified reference when constructing, clone and modify the properties of the original object has no effect $c->t($a); //Class B specified external references, clone modify properties directly affect the original object properties $c->t($b);
You have javascript disabled. You will not be able to edit any code.