Re: Includes confusion
| From: | Christina | Date: | Sun, 06 Apr 2003 20:02:31 +0000 |
| Subject: | Re: Includes confusion | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142610@lists.php.net to get a copy of this message | ||
Mike Tuller wrote:
I can't figure this out. I have a line where I include a file include "/Library/WebServer/includes/database_connection.inc"; I want to have this declared in one location, so that I don't have to change multiple lines if I ever move the application, everything works fine except inside functions. So if I have the following: include "/Library/WebServer/includes/database_connection.inc"; function list_search_results() {It won't work because the variables in database_connection.inc are not declared as globals in the function. <?php include "/Library/WebServer/includes/database_connection.inc"; function list_search_results() { global $variable1, $variable2, $variable3; // modify this // my code that lists 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? Mike