Re: [PHP] Global Var Disappearing After Function

[email protected] (Andrew Ballard)
Newsgroups php.general
Message-ID <[email protected]>
On Mon, Mar 22, 2010 at 4:58 PM, APseudoUtopia <[email protected]> wrote:
> Hey list,
>
> I have a very odd problem which has been driving me crazy for two
> days. I've been trying to debug my code and gave up. I finally coded a
> very simple representation of what the code does, and I get the same
> problem. However, I still don't understand what's causing it.
>
> The representational code:
> http://pastie.org/private/fz3lgvsjopz3dhid8cf9a
>
> As you can see, it's very simple. A variable is set, then a function
> is called which modifies the variable in the global scope. However,
> the modifications CANNOT BE SEEN after the function is called.
>
> The output from the script is here:
> http://pastie.org/private/29r5mrr1k7rtqmw7eyoja
>
> As you can see, the modifications in do_test() cannot be seen after
> the function is called.
>
> What is causing this? And how can I fix it?
>
> Thanks!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I believe line 8 detaches the variable $Session that exists inside the
function from the global variable that exists outside the function.

Andrew
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.