Re: unexpected modification of a variable
| From: | Ángel González | Date: | Wed, 29 Jun 2011 22:25:06 +0000 |
| Subject: | Re: unexpected modification of a variable | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-53688@lists.php.net to get a copy of this message | ||
Pascal COURTOIS wrote:
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 ? Maybe the prototype of anotherfunction() receives it by reference.Another option would be that <some code> sets some global as a reference to $var, and $var is changed through it. If you have such problem, you should provide a test case. But it's probably a bug in your code that will get solved when piecing it.