Re: Scope of include
| From: | Stut | Date: | Thu, 18 Jan 2007 21:12:07 +0000 |
| Subject: | Re: Scope of include | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247365@lists.php.net to get a copy of this message | ||
Robert Cummings wrote:
To answer his question though, variables not declared via the "global" keyword and not accessed via the super global variables ($GLOBALS, $_SESSION, etc) inherit the scope in which the include statement occurs. Therefore, if in the included file all you have is:It's important to have this clear in your head when dealing with included files, so I wrote an example that will hopefully demonstrate it for the OP...$foo = 'foo';Then it's scope is the function including the file.
http://dev.stut.net/php/scope/-Stut