unexpected modification of a variable
| From: | Pascal COURTOIS | Date: | Wed, 29 Jun 2011 14:53:47 +0000 |
| Subject: | unexpected modification of a variable | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-53658@lists.php.net to get a copy of this message | ||
Hi,
Is there any way that a variable can be changed within a function without passing it by reference ?
I have a code like that:
function myfunction($var)
{
<some code>
print_r($var); => prints $var which is an object
anotherfunction($var); // call by value
print_r($var); => $var has changed
}
I thought that since there's no reference in any way to the variable it cannot be changed in
the function. Am I wrong ?