include files and global variables
| From: | Jon Wyatt | Date: | Sun, 21 Jul 2002 21:20:05 +0000 |
| Subject: | include files and global variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-108744@lists.php.net to get a copy of this message | ||
I have some pages which include a number of files.
In one of the include files I have a function which I wish to be executed everytime the include file is loaded.
Therefore I place the function name in the include file at the top.
However, this function uses a session variable to decide whether to call another function and it appears that this variable is not being carried across. For example, the start of the include file might look like this:-
<?php
checkMaster();
function checkMaster()
{
global $master_session;
if ($master_session[db_host])
{
connectToDB();
}
}
function connectToDB()
{
...
....
The master_session variable is not set and hence connectToDB is never called.
If I place the checkMaster code in each page that includes this file then it all works fine. How do I get round this?
Thanks.
jon.
Better than having your body rubbed vigorously with a cheese grater.
http://www.samuri.co.uk.
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx