Re: include files and global variables

From: Date: Mon, 22 Jul 2002 10:20:28 +0000
Subject: Re: include files and global variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-108779@lists.php.net to get a copy of this message
I think that you need to call the checkMaster() function AFTER you declare it, not before. Try moving "checkMaster();" beneath the function definition. Mick On Sun, 21 Jul 2002, Jon Wyatt wrote: > > 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 > > > -- -------------------------------- n i n t i . c o m php-python-perl-mysql-postgresql -------------------------------- Michael Hall ninti@ninti.com --------------------------------

« previous php.general (#108779) next »