There are two objects of the same class:
$obj1 = new MyClass();
$obj2 = new MyClass();
Then I applied a function func
to $obj2
. However, once this function is executed, I noticed that the content of $obj1
has magically changed as well. I do not use any reference to $obj1
inside func
. What might be the possible reasons of this problem? How do I solve it?
$obj2 = func($obj2,$vars);
I should say that I use other functions before func
, and they also use $obj2
as an input. However, after their execution the content of $obj1
get not changed.
P.S. When I debug this code in Zend Studio and go inside func, Watch list Expressions says that $obj1 = null
, but I think it's fine, because func
is saved in a different PHP file.