$GLOBALS problem
| From: | Andy Tawse | Date: | Tue, 06 Aug 2002 13:17:16 +0000 |
| Subject: | $GLOBALS problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-111364@lists.php.net to get a copy of this message | ||
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.