Re: $GLOBALS array
| From: | Gaylen Fraley | Date: | Mon, 24 Dec 2001 00:35:33 +0000 |
| Subject: | Re: $GLOBALS array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-78634@lists.php.net to get a copy of this message | ||
Why aren't you using the $_POST or $HTTP_POST_VARS array?
--
Gaylen
gfraley5@earthlink.net
Home http://www.gaylenandmargie.com/
PHP KISGB v2.6 Guest Book http://www.gaylenandmargie.com/phpwebsite/
"Philip Maciver" <philipmaciver@yahoo.com> wrote in message
news:20011224000848.4e893de7.philipmaciver@yahoo.com...
> Does anyone know if it is possible to use the
>
> 'global $varName'
>
> function with the '$GLOBALS' array itself.
>
> I have been having some trouble with this. I have decieded to switch of
register_globals in the php.ini file (seeing as
> it is now deprecated in version 4.1.0)
> I know that register_globals is still supported, but I would like to get
used to not using it.
> But anyway, the problem I am having is that when I post data from a form
to another page the data is not available
> globally, so I wrote a method to register them globally, it looks like
this
>
> function globaliseVars($varArray) {
> global $GLOBALS;
>
> while (list($varName,$var) = each($varArray)) {
> $GLOBALS[trim($varName)] = trim($var);
> }
> }
>
> But doing 'global $GLOBALS' doesn't seem to make it refer to the actual
'$GLOBALS' array, the only time it did work was
> when I place something into the '$GLOBALS' array on the page that calls
the function. So
>
> /**
> * This doesn't work
> */
> globaliseVars($HTTP_POST_VARS);
>
>
> /**
> * But this does
> */
> $GLOBALS["ANYTHING"] = "anything";
> globaliseVars($HTTP_POST_VARS);
>
> If anyone could help me with this problem please could they get in touch,
because its driving me crazy.
>
> Thanks!
>
> ==============
> Philip MacIver