Re: $GLOBALS problem

From: Date: Tue, 06 Aug 2002 13:34:21 +0000
Subject: Re: $GLOBALS problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-111365@lists.php.net to get a copy of this message
Could you paste few lines of code that shows this problem as well as output from the browser. Thanks. Regards, Andrey ----- Original Message ----- From: "Andy Tawse" <andy.t@newmediacollective.com> To: <php-general@lists.php.net> Sent: Tuesday, August 06, 2002 4:17 PM Subject: [PHP] $GLOBALS problem > hello all. > > I'm having a very strange problem involving the $GLOBALS array. I have a global variable defined called $journal_month and I've been trying to access it from inside a function like so: > > $months = $GLOBALS["journal_month"]; > > but I was getting an 'undefined index' error. The variable dump confirmed that PHP didnt think there was a global variable called journal_month. I have used $GLOBALS countless other times in the > script with no problems and have actually been able to refer to $GLOBALS["journal_month"] from a different function. So I tried: > > global $journal_month; > > and it worked!? > > I didnt think there was any difference between the $GLOBALs array and using the global statement. > > The variable is an array and is defined near the top of the script. This script is 'require'd by the main one. > > I'm running Win2000 and PHP 4.2.1 as an Apache module. > > Thanks for any help > > Andy. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#111365) next »