At 22:24 04.04.2003, Mike Tuller said:
--------------------[snip]--------------------
>fine except inside functions. So if I have the following:
>
>include "/Library/WebServer/includes/database_connection.inc";
>
>function list_search_results()
>{
>       // my code that lists search results
>}
>
>The functions returns an error, but if I do this:
>
>
>function list_search_results()
>{
>       include "/Library/WebServer/includes/database_connection.inc";
>       // my code that lists search results
>}
>
>Everything works fine. Shouldn't the function be able to use the 
>include file when it is declared outside the function?
--------------------[snip]-------------------- 

This depends on the contents of your library. If you have it included
within the function, all variables and data structures created within the
included file are within the function's scope. If included outside, they're
on a global scope - you would need to use either the $GLOBAL superglobal
array, or to declare them being global within the function that uses them.


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/



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

Reply via email to