Re: included file var scope

From: Date: Mon, 07 Apr 2008 14:58:18 +0000
Subject: Re: included file var scope
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-272638@lists.php.net to get a copy of this message
Evert Lammerts wrote:
In index.php rather than declaring vars like so... $var = 'value'; ...declare them in the $GLOBALS array like so... $GLOBALS['var'] = 'value'; $var is then in the global scope regardless of where it was set. -Stut
That would work. However I'm looking for a more generic solution, independent of the system that is being included. So basically I want to be able to include a file in my function while stepping out of the context of the function itself.
I'm not sure what you mean. If you're saying you want to include a file from inside a function but for all parts of it to behave as if it were being included at the global scope then I don't believe there's a way to do it. Maybe it would be better if you tell us exactly what you're trying to achieve. I don't really see why my solution above would not work so I probably don't fully understand what you're trying to do. -Stut -- http://stut.net/

« previous php.general (#272638) next »