Changing the value of a variable that is a parameter in the parent scope <p>Is there any way to change the value of a parameter in the parent scope without passing it by reference to the child scope? I'd like to do something like this:</p> <pre><code>function foo($x = 5) { bar(); echo $x; // Ideally should output 6 } function bar() { $x = 6; } foo(); </code></pre> <p>In the scope of bar, I can get the value of $x by using debug_backtrace() or ReflectionFunction::getParameters, but I can't get a reference to $x!! Can this be done? I don't care if the solution is kind of a hack.</p> <p>(To reiterate, I KNOW that I could just pass $x by reference to bar.)</p>