Re: Include and require

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, August 14, 2006 4:20 pm, Dave Goodchild wrote:
> Hi all - I have several require_once statements in my web app to load
> in
> small function libraries. A common one bundles a variety of functions
> to
> handle date math and map month numbers to month names. I originally
> defined
> an array in that file plus a bunch of functions but when I loaded the
> page,
> the array variable, referenced further down the page, was NULL. I
> wrapped a
> function def around the array and returned it and all was fine.
>
> I may be suffering from mild hallucinations, but can you not define
> variables in a required file? It is not a scope issue as the array
> variable
> is referenced in the web page, not in any function.

Be 100% sure that the include_once is not being done inside of another
function...

If you can't figure it out, one quick test is to put 'global ' in
front of the variable.

If that fixes the problem, then you know that you DO in fact have a
scope issue, whether you know why you have it or not. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux